WIP: map CMS data to Tracking

This commit is contained in:
Arvid Norlin
2024-02-13 15:53:26 +01:00
parent 5bd162da10
commit 5b3b47b568
3 changed files with 25 additions and 5 deletions

View File

@@ -7,6 +7,7 @@ import ContentPage from "@/components/Current/ContentPage"
import type { PageArgs, LangParams, UriParams } from "@/types/params"
import type { GetCurrentBlockPageData } from "@/types/requests/currentBlockPage"
import Tracking from "../../Tracking"
export default async function CurrentContentPage({
params,
@@ -31,13 +32,24 @@ export default async function CurrentContentPage({
console.log("SearchParams URI: ", searchParams.uri)
throw new Error("Not found")
}
const pageData = response.data.all_current_blocks_page.items[0]
const trackingData = {
pageName: pageData.title,
pageType: pageData.system.content_type_uid,
publishedDate: pageData.system.updated_at,
createdDate: pageData.system.created_at,
pageId: pageData.system.uid,
}
return (
<ContentPage
data={response.data}
uri={searchParams.uri}
lang={params.lang}
/>
<>
<ContentPage
data={response.data}
uri={searchParams.uri}
lang={params.lang}
/>
<Tracking pageData={trackingData} />
</>
)
} catch (err) {
return notFound()

View File

@@ -31,6 +31,8 @@ query GetCurrentBlockPage($locale: String!, $url: String!) {
system {
uid
content_type_uid
created_at
updated_at
}
}
total

View File

@@ -48,6 +48,12 @@ export type BlockPage = {
preamble: Preamble
title: string
url: string
system: {
uid: string
content_type_uid: string // should this be locked down to the specific enum?
created_at: string
updated_at: string
}
}
export type GetCurrentBlockPageData = {