49 lines
1.8 KiB
TypeScript
49 lines
1.8 KiB
TypeScript
import { getPostBySlug, getPostSlugs } from '@/lib/mdx';
|
|
import { notFound } from 'next/navigation';
|
|
|
|
import { getPublicationsData } from '@/lib/publications';
|
|
import { Article } from '@/components/page-article';
|
|
import { DATA } from '@/app/resume';
|
|
|
|
export async function generateStaticParams() {
|
|
const slugs = getPostSlugs('projects');
|
|
return slugs.map((slug) => ({ slug }));
|
|
}
|
|
|
|
export async function generateMetadata({ params }: { params: { slug: string } }) {
|
|
// FIX: Await params to get slug for Next.js 15
|
|
const { slug } = await params;
|
|
|
|
const post = await getPostBySlug('projects', slug);
|
|
if (!post) { return {}; }
|
|
return {
|
|
title: post.frontmatter.title,
|
|
description: post.frontmatter.teaser || DATA.description,
|
|
};
|
|
}
|
|
|
|
export default async function ProjectPage({ params }: { params: { slug: string } }) {
|
|
// FIX: Await params to get slug for Next.js 15
|
|
const { slug } = await params;
|
|
|
|
const post = await getPostBySlug('projects', slug);
|
|
const publications = getPublicationsData();
|
|
|
|
if (!post) {
|
|
notFound();
|
|
}
|
|
|
|
// --- Navigation Logic ---
|
|
const allSlugs = getPostSlugs('projects');
|
|
const currentIndex = allSlugs.findIndex((s) => s === slug);
|
|
const prevSlug = currentIndex > 0 ? allSlugs[currentIndex - 1] : null;
|
|
const nextSlug = currentIndex < allSlugs.length - 1 ? allSlugs[currentIndex + 1] : null;
|
|
const prevPost = prevSlug ? await getPostBySlug('projects', prevSlug) : null;
|
|
const nextPost = nextSlug ? await getPostBySlug('projects', nextSlug) : null;
|
|
const navigation = {
|
|
prev: prevPost ? { slug: prevSlug, title: prevPost.frontmatter.title } : null,
|
|
next: nextPost ? { slug: nextSlug, title: nextPost.frontmatter.title } : null,
|
|
};
|
|
|
|
return <Article post={post} publications={publications} navigation={navigation} basePath="projects" />;
|
|
} |