chore(SW-194): ContentPage Accordion
This commit is contained in:
@@ -2,6 +2,10 @@ import { z } from "zod"
|
||||
|
||||
import { discriminatedUnionArray } from "@/lib/discriminatedUnion"
|
||||
|
||||
import {
|
||||
accordionRefsSchema,
|
||||
accordionSchema,
|
||||
} from "../schemas/blocks/accordion"
|
||||
import {
|
||||
cardGridRefsSchema,
|
||||
cardsGridSchema,
|
||||
@@ -81,8 +85,14 @@ export const contentPageTable = z
|
||||
__typename: z.literal(ContentPageEnum.ContentStack.blocks.Table),
|
||||
})
|
||||
.merge(tableSchema)
|
||||
export const contentPageAccordion = z
|
||||
.object({
|
||||
__typename: z.literal(ContentPageEnum.ContentStack.blocks.Accordion),
|
||||
})
|
||||
.merge(accordionSchema)
|
||||
|
||||
export const blocksSchema = z.discriminatedUnion("__typename", [
|
||||
contentPageAccordion,
|
||||
contentPageCards,
|
||||
contentPageContent,
|
||||
contentPageDynamicContent,
|
||||
@@ -192,7 +202,14 @@ const contentPageUspGridRefs = z
|
||||
})
|
||||
.merge(uspGridRefsSchema)
|
||||
|
||||
const contentPageAccordionRefs = z
|
||||
.object({
|
||||
__typename: z.literal(ContentPageEnum.ContentStack.blocks.Accordion),
|
||||
})
|
||||
.merge(accordionRefsSchema)
|
||||
|
||||
const contentPageBlockRefsItem = z.discriminatedUnion("__typename", [
|
||||
contentPageAccordionRefs,
|
||||
contentPageBlockContentRefs,
|
||||
contentPageShortcutsRefs,
|
||||
contentPageCardsRefs,
|
||||
|
||||
@@ -25,6 +25,7 @@ export const contentPageQueryRouter = router({
|
||||
const { lang, uid } = ctx
|
||||
|
||||
const contentPageRefsData = await fetchContentPageRefs(lang, uid)
|
||||
|
||||
const contentPageRefs = validateContentPageRefs(
|
||||
contentPageRefsData,
|
||||
lang,
|
||||
@@ -33,8 +34,10 @@ export const contentPageQueryRouter = router({
|
||||
if (!contentPageRefs) {
|
||||
return null
|
||||
}
|
||||
//console.log("EYY", contentPageRefs.content_page.blocks[1])
|
||||
//console.log("EYY", contentPageRefs.content_page.blocks[0])
|
||||
const tags = generatePageTags(contentPageRefs, lang)
|
||||
|
||||
//console.log("tags", tags)
|
||||
getContentPageCounter.add(1, { lang, uid })
|
||||
console.info(
|
||||
"contentstack.contentPage start",
|
||||
@@ -83,7 +86,7 @@ export const contentPageQueryRouter = router({
|
||||
console.error(contentPage.error?.format())
|
||||
return null
|
||||
}
|
||||
|
||||
//console.log("HEJ2", contentPage.data.content_page.blocks[0])
|
||||
const tracking: TrackingSDKPageData = {
|
||||
pageId: contentPage.data.content_page.system.uid,
|
||||
lang: contentPage.data.content_page.system.locale as Lang,
|
||||
|
||||
@@ -126,6 +126,12 @@ export function getConnections({ content_page }: ContentPageRefs) {
|
||||
if (content_page.blocks) {
|
||||
content_page.blocks.forEach((block) => {
|
||||
switch (block.__typename) {
|
||||
case ContentPageEnum.ContentStack.blocks.Accordion: {
|
||||
if (block.accordion.length) {
|
||||
connections.push(...block.accordion)
|
||||
}
|
||||
break
|
||||
}
|
||||
case ContentPageEnum.ContentStack.blocks.Content:
|
||||
{
|
||||
if (block.content.length) {
|
||||
|
||||
Reference in New Issue
Block a user