2023-10-23 23:11:59 +02:00
|
|
|
import { notFound } from "next/navigation"
|
|
|
|
import date from "date-and-time"
|
2023-08-01 18:59:45 +02:00
|
|
|
|
2023-10-23 23:11:59 +02:00
|
|
|
import "katex/dist/katex.min.css"
|
2023-08-01 18:59:45 +02:00
|
|
|
|
2023-10-23 23:11:59 +02:00
|
|
|
import { getBlogPostBySlug } from "@/blog/blog"
|
|
|
|
import { BlogPostContent } from "@/blog/BlogPostContent"
|
2023-08-01 18:59:45 +02:00
|
|
|
|
|
|
|
export interface BlogPostProps {
|
|
|
|
slug: string
|
|
|
|
}
|
|
|
|
|
|
|
|
export const BlogPost = async (props: BlogPostProps): Promise<JSX.Element> => {
|
|
|
|
const { slug } = props
|
|
|
|
|
|
|
|
const blogPost = await getBlogPostBySlug(slug)
|
|
|
|
if (blogPost == null) {
|
|
|
|
return notFound()
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
2023-10-23 23:11:59 +02:00
|
|
|
<main className="break-wrap-words flex flex-1 flex-col flex-wrap items-center justify-center">
|
|
|
|
<div className="my-10 flex flex-col items-center text-center">
|
|
|
|
<h1 className="text-3xl font-semibold">{blogPost.frontmatter.title}</h1>
|
|
|
|
<p className="mt-2" data-cy="blog-post-date">
|
2023-08-01 18:59:45 +02:00
|
|
|
{date.format(
|
|
|
|
new Date(blogPost.frontmatter.publishedOn),
|
2023-10-23 23:11:59 +02:00
|
|
|
"DD/MM/YYYY",
|
2023-08-01 18:59:45 +02:00
|
|
|
)}
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
<BlogPostContent content={blogPost.content} />
|
|
|
|
</main>
|
|
|
|
)
|
|
|
|
}
|