From 1c90bf55f026ef1cb205b8998fb7384f42e863ac Mon Sep 17 00:00:00 2001 From: jendiamond Date: Thu, 7 Nov 2024 15:05:40 -0800 Subject: [PATCH 01/20] create composable and add it to all slug pages --- gql/queries/FTVAArticleDetail.gql | 1 + gql/queries/FTVACollectionDetail.gql | 5 +++-- gql/queries/FTVAEventDetail.gql | 1 + gql/queries/FTVAEventSeriesDetail.gql | 3 +++ pages/blog/[slug].vue | 22 +++++++++++++++++++++- pages/collections/[slug].vue | 25 +++++++++++++++++++++++-- pages/events/[slug].vue | 16 ++++++++++++++++ pages/series/[slug].vue | 23 +++++++++++++++++++++-- 8 files changed, 89 insertions(+), 7 deletions(-) diff --git a/gql/queries/FTVAArticleDetail.gql b/gql/queries/FTVAArticleDetail.gql index d5081f0..bbe5226 100644 --- a/gql/queries/FTVAArticleDetail.gql +++ b/gql/queries/FTVAArticleDetail.gql @@ -5,6 +5,7 @@ query FTVAArticleDetail($slug: [String!]) { ftvaArticle: entry(section: "ftvaArticle", slug: $slug) { id typeHandle + sectionHandle postDate slug title diff --git a/gql/queries/FTVACollectionDetail.gql b/gql/queries/FTVACollectionDetail.gql index 9c71179..7df5623 100644 --- a/gql/queries/FTVACollectionDetail.gql +++ b/gql/queries/FTVACollectionDetail.gql @@ -2,8 +2,9 @@ query FTVACollectionDetail($slug: [String!]) { ftvaCollection: entry(section: "ftvaCollection", slug: $slug) { + id typeHandle - id + sectionHandle imageCarousel { ... on imageCarousel_imageCarousel_BlockType { image { @@ -15,7 +16,7 @@ query FTVACollectionDetail($slug: [String!]) { title sectionTitle ftvaCollectionType - richText + richText videoEmbed viewAllSectionLink { ... on viewAllSectionLink_viewAllSection_BlockType { diff --git a/gql/queries/FTVAEventDetail.gql b/gql/queries/FTVAEventDetail.gql index b1bdaf0..1a29acc 100644 --- a/gql/queries/FTVAEventDetail.gql +++ b/gql/queries/FTVAEventDetail.gql @@ -4,6 +4,7 @@ query FTVAEventDetail($slug: [String!]) { ftvaEvent: entry(section: "ftvaEvent", slug: $slug) { id typeHandle + sectionHandle slug uri diff --git a/gql/queries/FTVAEventSeriesDetail.gql b/gql/queries/FTVAEventSeriesDetail.gql index a3e7360..5cd9fa6 100644 --- a/gql/queries/FTVAEventSeriesDetail.gql +++ b/gql/queries/FTVAEventSeriesDetail.gql @@ -10,6 +10,9 @@ query FTVAEventSeriesDetail ($slug: [String!]) { creditText } } + id + typeHandle + sectionHandle title guestSpeaker ftvaEventIntroduction diff --git a/pages/blog/[slug].vue b/pages/blog/[slug].vue index c9d31ff..90e7dd9 100644 --- a/pages/blog/[slug].vue +++ b/pages/blog/[slug].vue @@ -8,12 +8,19 @@ import { // HELPERS import _get from 'lodash/get' -import FTVAArticleDetail from '../gql/queries/FTVAArticleDetail.gql' import removeTags from '~/utils/removeTags' // GQL +import FTVAArticleDetail from '../gql/queries/FTVAArticleDetail.gql' + +// COMPOSABLE +import { useContentIndexer } from '/composables/useContentIndexer' + import socialList from '~/utils/socialList' +// COMPOSABLE +import { useContentIndexer } from '/composables/useContentIndexer' + const { $graphql } = useNuxtApp() const route = useRoute() @@ -37,6 +44,19 @@ if (!data.value.ftvaArticle) { }) } +// This is creating an index of the main content (not related content) +if (data.value.ftvaArticle && import.meta.prerender) { + try { + // Call the composable to use the indexing function + const { indexContent } = useContentIndexer() + // Index the article data using the composable during static build + await indexContent(data.value.ftvaArticle, route.params.slug) + console.log('Article indexed successfully during static build') + } catch (error) { + console.error('Failed to index article during static build:', error) + } +} + const page = ref(_get(data.value, 'ftvaArticle', {})) const ftvaRecentPosts = ref(_get(data.value, 'ftvaRecentPosts', {})) diff --git a/pages/collections/[slug].vue b/pages/collections/[slug].vue index 017482d..b9f5ee7 100644 --- a/pages/collections/[slug].vue +++ b/pages/collections/[slug].vue @@ -6,10 +6,14 @@ import { BlockCallToAction, CardMeta, DividerWayFinder, NavBreadcrumb, Responsiv // HELPERS import _get from 'lodash/get' -import FTVACollectionDetail from '../gql/queries/FTVACollectionDetail.gql' import removeTags from '~/utils/removeTags' // GQL +import FTVACollectionDetail from '../gql/queries/FTVACollectionDetail.gql' + +// COMPOSABLE +import { useContentIndexer } from '/composables/useContentIndexer' + import socialList from '~/utils/socialList' const { $graphql } = useNuxtApp() @@ -35,6 +39,19 @@ if (!data.value.ftvaCollection) { }) } +// This is creating an index of the main content (not related content) +if (data.value.ftvaCollection && import.meta.prerender) { + try { + // Call the composable to use the indexing function + const { indexContent } = useContentIndexer() + // Index the collection data using the composable during static build + await indexContent(data.value.ftvaCollection, route.params.slug) + console.log('Collection indexed successfully during static build') + } catch (error) { + console.error('Failed to collection event during static build:', error) + } +} + const page = ref(_get(data.value, 'ftvaCollection', {})) watch(data, (newVal, oldVal) => { @@ -240,7 +257,11 @@ useHead({ -