diff --git a/customtypes/marketing/index.json b/customtypes/marketing/index.json new file mode 100644 index 0000000..824e9b4 --- /dev/null +++ b/customtypes/marketing/index.json @@ -0,0 +1,55 @@ +{ + "format": "page", + "id": "marketing", + "label": "Marketing", + "repeatable": true, + "status": true, + "json": { + "Main": { + "uid": { + "type": "UID", + "config": { + "label": "UID" + } + }, + "slices": { + "type": "Slices", + "fieldset": "Slice Zone", + "config": { + "choices": { + "hero": { + "type": "SharedSlice" + } + } + } + } + }, + "SEO & Metadata": { + "meta_title": { + "config": { + "label": "Meta Title", + "placeholder": "A title of the page used for social media and search engines" + }, + "type": "Text" + }, + "meta_description": { + "config": { + "label": "Meta Description", + "placeholder": "A brief summary of the page" + }, + "type": "Text" + }, + "meta_image": { + "config": { + "constraint": { + "height": 1260, + "width": 2400 + }, + "label": "Meta Image", + "thumbnails": [] + }, + "type": "Image" + } + } + } +} diff --git a/prismicio-types.d.ts b/prismicio-types.d.ts index 7039c94..3994534 100644 --- a/prismicio-types.d.ts +++ b/prismicio-types.d.ts @@ -900,6 +900,71 @@ export type LegalHomeDocument = Lang >; +type MarketingDocumentDataSlicesSlice = HeroSlice; + +/** + * Content for Marketing documents + */ +interface MarketingDocumentData { + /** + * Slice Zone field in *Marketing* + * + * - **Field Type**: Slice Zone + * - **Placeholder**: *None* + * - **API ID Path**: marketing.slices[] + * - **Tab**: Main + * - **Documentation**: https://prismic.io/docs/field#slices + */ + slices: prismic.SliceZone /** + * Meta Title field in *Marketing* + * + * - **Field Type**: Text + * - **Placeholder**: A title of the page used for social media and search engines + * - **API ID Path**: marketing.meta_title + * - **Tab**: SEO & Metadata + * - **Documentation**: https://prismic.io/docs/field#key-text + */; + meta_title: prismic.KeyTextField; + + /** + * Meta Description field in *Marketing* + * + * - **Field Type**: Text + * - **Placeholder**: A brief summary of the page + * - **API ID Path**: marketing.meta_description + * - **Tab**: SEO & Metadata + * - **Documentation**: https://prismic.io/docs/field#key-text + */ + meta_description: prismic.KeyTextField; + + /** + * Meta Image field in *Marketing* + * + * - **Field Type**: Image + * - **Placeholder**: *None* + * - **API ID Path**: marketing.meta_image + * - **Tab**: SEO & Metadata + * - **Documentation**: https://prismic.io/docs/field#image + */ + meta_image: prismic.ImageField; +} + +/** + * Marketing document from Prismic + * + * - **API ID**: `marketing` + * - **Repeatable**: `true` + * - **Documentation**: https://prismic.io/docs/custom-types + * + * @typeParam Lang - Language API ID of the document. + */ +export type MarketingDocument = + prismic.PrismicDocumentWithUID< + Simplify, + "marketing", + Lang + >; + type PageDocumentDataSlicesSlice = | BenefitsSlice | FeaturesSlice @@ -1278,6 +1343,7 @@ export type AllDocumentTypes = | LayoutDocument | LegalDocument | LegalHomeDocument + | MarketingDocument | PageDocument | ServicesDocument | SettingsDocument @@ -3428,6 +3494,9 @@ declare module "@prismicio/client" { LegalHomeDocument, LegalHomeDocumentData, LegalHomeDocumentDataSlicesSlice, + MarketingDocument, + MarketingDocumentData, + MarketingDocumentDataSlicesSlice, PageDocument, PageDocumentData, PageDocumentDataSlicesSlice, diff --git a/src/app/(frontend)/[lang]/(pages)/[uid]/page.tsx b/src/app/(frontend)/[lang]/(pages)/[uid]/page.tsx new file mode 100644 index 0000000..f8822a9 --- /dev/null +++ b/src/app/(frontend)/[lang]/(pages)/[uid]/page.tsx @@ -0,0 +1,61 @@ +import { createClient } from "@/prismicio"; +import { components } from "@/slices"; +import { asImageSrc, isFilled } from "@prismicio/client"; +import { SliceZone } from "@prismicio/react"; +import type { Metadata } from "next"; +import { notFound } from "next/navigation"; + +type Params = { + lang: string; + uid: string; +}; + +type Props = { + params: Promise; +}; + +export default async function PrismigPage(props: Props) { + const params = await props.params; + + const client = createClient(); + const page = await client + .getByUID("marketing", params.uid, { lang: params.lang }) + .catch(() => notFound()); + + return ; +} + +export async function generateMetadata({ params }: Props): Promise { + const { uid, lang } = await params; + const client = createClient(); + const page = await client + .getByUID("marketing", uid, { lang }) + .catch(() => notFound()); + + return { + title: page.data.meta_title, + description: page.data.meta_description, + openGraph: { + title: isFilled.keyText(page.data.meta_title) + ? page.data.meta_title + : undefined, + description: isFilled.keyText(page.data.meta_description) + ? page.data.meta_description + : undefined, + images: isFilled.image(page.data.meta_image) + ? [asImageSrc(page.data.meta_image)] + : undefined, + }, + }; +} + +export async function generateStaticParams() { + const client = createClient(); + const pages = await client.getAllByType("marketing", { + lang: "*", + }); + + return pages.map((page) => { + return { uid: page.uid, lang: page.lang }; + }); +} diff --git a/src/prismicio.ts b/src/prismicio.ts index f55cd2c..e2edc14 100644 --- a/src/prismicio.ts +++ b/src/prismicio.ts @@ -52,6 +52,10 @@ const routes: prismic.ClientConfig["routes"] = [ type: "enterprise_home", path: "/:lang/enterprise", }, + { + type: "marketing", + path: "/:lang/:uid", + }, { type: "blog_home", path: "/:lang/blog",