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