The update implemented a redirect functionality in the multi-factor authentication flow for a better user experience. It also involved a refactoring of some parts of the code, substituting direct routing paths with path configs for easier future modifications. Import statements were adjusted for better code organization and readability.
71 lines
1.5 KiB
TypeScript
71 lines
1.5 KiB
TypeScript
import type { Metadata } from 'next';
|
|
|
|
import { notFound } from 'next/navigation';
|
|
import Script from 'next/script';
|
|
|
|
import { allPosts } from 'contentlayer/generated';
|
|
|
|
import Post from '~/(marketing)/blog/_components/post';
|
|
import appConfig from '~/config/app.config';
|
|
import { withI18n } from '~/lib/i18n/with-i18n';
|
|
|
|
export async function generateMetadata({
|
|
params,
|
|
}: {
|
|
params: { slug: string };
|
|
}): Promise<Metadata | undefined> {
|
|
const post = allPosts.find((post) => post.slug === params.slug);
|
|
|
|
if (!post) {
|
|
notFound();
|
|
}
|
|
|
|
const { title, date, description, image, slug } = post;
|
|
const url = [appConfig.url, 'blog', slug].join('/');
|
|
|
|
return {
|
|
title,
|
|
description,
|
|
openGraph: {
|
|
title,
|
|
description,
|
|
type: 'article',
|
|
publishedTime: date,
|
|
url,
|
|
images: image
|
|
? [
|
|
{
|
|
url: image,
|
|
},
|
|
]
|
|
: [],
|
|
},
|
|
twitter: {
|
|
card: 'summary_large_image',
|
|
title,
|
|
description,
|
|
images: image ? [image] : [],
|
|
},
|
|
};
|
|
}
|
|
|
|
function BlogPost({ params }: { params: { slug: string } }) {
|
|
const post = allPosts.find((post) => post.slug === params.slug);
|
|
|
|
if (!post) {
|
|
notFound();
|
|
}
|
|
|
|
return (
|
|
<div className={'container mx-auto'}>
|
|
<Script id={'ld-json'} type="application/ld+json">
|
|
{JSON.stringify(post.structuredData)}
|
|
</Script>
|
|
|
|
<Post post={post} content={post.body.code} />
|
|
</div>
|
|
);
|
|
}
|
|
|
|
export default withI18n(BlogPost);
|