-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f234e10
commit 277a105
Showing
4 changed files
with
189 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Params>; | ||
}; | ||
|
||
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 <SliceZone slices={page.data.slices} components={components} />; | ||
} | ||
|
||
export async function generateMetadata({ params }: Props): Promise<Metadata> { | ||
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 }; | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters