The codebase has been updated throughout to improve debugging capabilities notably in the PostgresDatabaseWebhookVerifierService and create-reader modules. User interface has also been enhanced in the marketing layout and blog page. Minor reordering of entries in email-templates and adjustment of configurations in turbo.json has also been performed.
73 lines
1.4 KiB
TypeScript
73 lines
1.4 KiB
TypeScript
import { cache } from 'react';
|
|
|
|
import type { Metadata } from 'next';
|
|
|
|
import { notFound } from 'next/navigation';
|
|
|
|
import { createCmsClient } from '@kit/cms';
|
|
|
|
import { withI18n } from '~/lib/i18n/with-i18n';
|
|
|
|
import { Post } from '../../blog/_components/post';
|
|
|
|
const getPostBySlug = cache(async (slug: string) => {
|
|
const client = await createCmsClient();
|
|
|
|
return client.getContentItemBySlug({ slug, collection: 'posts' });
|
|
});
|
|
|
|
export async function generateMetadata({
|
|
params,
|
|
}: {
|
|
params: { slug: string };
|
|
}): Promise<Metadata | undefined> {
|
|
const post = await getPostBySlug(params.slug);
|
|
|
|
if (!post) {
|
|
notFound();
|
|
}
|
|
|
|
const { title, publishedAt, description, image } = post;
|
|
|
|
return Promise.resolve({
|
|
title,
|
|
description,
|
|
openGraph: {
|
|
title,
|
|
description,
|
|
type: 'article',
|
|
publishedTime: publishedAt,
|
|
url: post.url,
|
|
images: image
|
|
? [
|
|
{
|
|
url: image,
|
|
},
|
|
]
|
|
: [],
|
|
},
|
|
twitter: {
|
|
card: 'summary_large_image',
|
|
title,
|
|
description,
|
|
images: image ? [image] : [],
|
|
},
|
|
});
|
|
}
|
|
|
|
async function BlogPost({ params }: { params: { slug: string } }) {
|
|
const post = await getPostBySlug(params.slug);
|
|
|
|
if (!post) {
|
|
notFound();
|
|
}
|
|
|
|
return (
|
|
<div className={'container sm:max-w-none sm:p-0'}>
|
|
<Post post={post} content={post.content} />
|
|
</div>
|
|
);
|
|
}
|
|
|
|
export default withI18n(BlogPost);
|