81 lines
2.7 KiB
TypeScript
81 lines
2.7 KiB
TypeScript
import { getPostBySlug, getPostSlugs } from '@/lib/mdx';
|
|
import { CitationProvider } from '@/components/context-citation';
|
|
import { ReferencesContainer } from '@/components/container-references';
|
|
import { notFound } from 'next/navigation';
|
|
import Image from 'next/image';
|
|
import { DATA } from '@/app/resume';
|
|
import { getPublicationsData } from '@/lib/publications';
|
|
import { CustomMDX } from '@/components/mdx-custom';
|
|
import Link from 'next/link';
|
|
|
|
export async function generateStaticParams() {
|
|
const slugs = getPostSlugs('blog');
|
|
return slugs.map((slug) => ({ slug }));
|
|
}
|
|
|
|
export async function generateMetadata({ params: { slug } }: { params: { slug: string } }) {
|
|
const post = await getPostBySlug('blog', slug);
|
|
if (!post) {
|
|
return {};
|
|
}
|
|
return {
|
|
title: post.frontmatter.title,
|
|
description: post.frontmatter.description || DATA.description,
|
|
};
|
|
}
|
|
|
|
export default async function BlogPage({ params: { slug } }: { params: { slug: string } }) {
|
|
const post = await getPostBySlug('blog', slug);
|
|
const publications = getPublicationsData();
|
|
|
|
if (!post) {
|
|
return notFound();
|
|
}
|
|
|
|
return (
|
|
<CitationProvider publications={publications}>
|
|
<main className="flex flex-col min-h-[100dvh]">
|
|
<article className="prose prose-stone dark:prose-invert max-w-none">
|
|
<header className="mb-8">
|
|
<h1 className="text-4xl font-bold tracking-tighter sm:text-5xl">
|
|
{post.frontmatter.title}
|
|
</h1>
|
|
{post.frontmatter.excerpt && (
|
|
<p className="text-lg text-muted-foreground mt-2">{post.frontmatter.excerpt}</p>
|
|
)}
|
|
{post.frontmatter.icon && (
|
|
<div className="mt-4">
|
|
<Image
|
|
src={post.frontmatter.icon}
|
|
alt={`${post.frontmatter.title} icon`}
|
|
width={64}
|
|
height={64}
|
|
className="rounded-full"
|
|
/>
|
|
</div>
|
|
)}
|
|
</header>
|
|
|
|
<CustomMDX {...post.source} />
|
|
|
|
{post.frontmatter.tags && (
|
|
<div className="flex flex-wrap gap-2 mt-8">
|
|
{post.frontmatter.tags.map((tag: string) => (
|
|
<Link
|
|
key={tag}
|
|
href={`/tags/${tag}`}
|
|
className="px-3 py-1 text-sm font-medium bg-secondary text-secondary-foreground rounded-full hover:bg-primary hover:text-primary-foreground transition-colors"
|
|
>
|
|
{tag}
|
|
</Link>
|
|
))}
|
|
</div>
|
|
)}
|
|
|
|
<ReferencesContainer />
|
|
</article>
|
|
</main>
|
|
</CitationProvider>
|
|
);
|
|
}
|