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 '@/utils/remarkSyntaxHighlightingPlugin' import { getPostBySlug } from '@/utils/blog' import { BlogPostComments } from '@/components/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 post = await getPostBySlug(props.params.slug) if (post == null || !post.frontmatter.isPublished) { return notFound() } const title = `${post.frontmatter.title} | Théo LUDWIG` const description = post.frontmatter.description return { title, description, openGraph: { title, description }, twitter: { title, description } } } const BlogPostPage = async (props: BlogPostPageProps): Promise => { const { params } = props const post = await getPostBySlug(params.slug) if (post == null || !post.frontmatter.isPublished) { return notFound() } const cookiesStore = cookies() const theme = getTheme() const highlighter = await getHighlighter({ theme: `${theme}-plus` }) return (

{post.frontmatter.title}

{date.format(new Date(post.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