1
1
mirror of https://github.com/theoludwig/theoludwig.git synced 2024-11-14 16:13:14 +01:00
.profile/app/blog/[slug]/page.tsx

45 lines
933 B
TypeScript
Raw Normal View History

import type { Metadata } from 'next'
import { notFound } from 'next/navigation'
import 'katex/dist/katex.min.css'
2023-08-01 17:44:08 +02:00
import { getBlogPostBySlug } from '@/blog/blog'
2023-08-01 18:59:45 +02:00
import { BlogPost } from '@/blog/BlogPost'
interface BlogPostPageProps {
params: {
slug: string
}
}
export const generateMetadata = async (
props: BlogPostPageProps
): Promise<Metadata> => {
2023-08-01 17:44:08 +02:00
const blogPost = await getBlogPostBySlug(props.params.slug)
2023-08-01 18:59:45 +02:00
if (blogPost == null) {
return notFound()
}
2023-08-01 17:44:08 +02:00
const title = `${blogPost.frontmatter.title} | Théo LUDWIG`
const description = blogPost.frontmatter.description
return {
title,
description,
openGraph: {
title,
description
},
twitter: {
title,
description
}
}
}
const BlogPostPage = async (props: BlogPostPageProps): Promise<JSX.Element> => {
const { params } = props
2023-08-01 18:59:45 +02:00
return <BlogPost slug={params.slug} />
}
export default BlogPostPage