import type { Metadata } from 'next' import { notFound } from 'next/navigation' import { cookies } from 'next/headers' import Link from 'next/link' import Image from 'next/image' import { MDXRemote } from 'next-mdx-remote/rsc' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { faLink } from '@fortawesome/free-solid-svg-icons' import date from 'date-and-time' import { nodeTypes } from '@mdx-js/mdx' import rehypeRaw from 'rehype-raw' import remarkGfm from 'remark-gfm' import rehypeSlug from 'rehype-slug' import remarkMath from 'remark-math' import rehypeKatex from 'rehype-katex' import { getHighlighter } from 'shiki' import 'katex/dist/katex.min.css' import { remarkSyntaxHighlightingPlugin } from '@/blog/remarkSyntaxHighlightingPlugin' import { getBlogPostBySlug } from '@/blog/blog' import { BlogPostComments } from '@/blog/BlogPostComments' import { getTheme } from '@/theme/theme.server' const Heading = ( props: React.DetailedHTMLProps< React.HTMLAttributes, HTMLHeadingElement > ): JSX.Element => { const { children, id = '' } = props return (

{children}

) } interface BlogPostPageProps { params: { slug: string } } export const generateMetadata = async ( props: BlogPostPageProps ): Promise => { const blogPost = await getBlogPostBySlug(props.params.slug) if (blogPost == null || !blogPost.frontmatter.isPublished) { return notFound() } 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 => { const { params } = props const blogPost = await getBlogPostBySlug(params.slug) if (blogPost == null || !blogPost.frontmatter.isPublished) { return notFound() } const cookiesStore = cookies() const theme = getTheme() const highlighter = await getHighlighter({ theme: `${theme}-plus` }) return (

{blogPost.frontmatter.title}

{date.format( new Date(blogPost.frontmatter.publishedOn), 'DD/MM/YYYY' )}

{ const { src = '', alt = 'Blog Image' } = properties const source = src.replace('../../public/', '/') return ( {alt} ) }, a: (props) => { const { href = '' } = props if (href.startsWith('#')) { return } return ( ) } }} />
) } export default BlogPostPage