56 lines
1.2 KiB
TypeScript
56 lines
1.2 KiB
TypeScript
import { getWikiPageBySlug } from '@/lib/wiki';
|
|
import { notFound } from 'next/navigation';
|
|
import rehypePrettyCode from 'rehype-pretty-code';
|
|
|
|
import { MDXRemote } from 'next-mdx-remote/rsc';
|
|
import { Callout, Grid, Card, Steps, Step, InlineCode, PreBlock } from '@/components/mdx-components';
|
|
|
|
const mdxOptions = {
|
|
mdxOptions: {
|
|
rehypePlugins: [
|
|
[
|
|
rehypePrettyCode,
|
|
{
|
|
theme: 'github-dark', // oder 'one-dark-pro', 'nord', etc.
|
|
keepBackground: true,
|
|
},
|
|
],
|
|
],
|
|
},
|
|
};
|
|
|
|
const mdxComponents = {
|
|
Callout,
|
|
Grid,
|
|
Card,
|
|
Steps,
|
|
Step,
|
|
h2: (props: any) => <h2 className="text-2xl font-bold text-white mt-12 mb-4" {...props} />,
|
|
};
|
|
|
|
type PageProps = {
|
|
params: Promise<{
|
|
slug: string;
|
|
}>;
|
|
};
|
|
|
|
export default async function Page({ params }: PageProps) {
|
|
const { slug } = await params;
|
|
const article = await getWikiPageBySlug(slug);
|
|
|
|
if (!article) {
|
|
notFound();
|
|
}
|
|
|
|
return (
|
|
<article className="prose prose-invert max-w-none p-6">
|
|
<h1>{article.title}</h1>
|
|
{/* Direkte MDX-Rendering-Komponente von Next.js */}
|
|
<MDXRemote
|
|
source={article.rawContent}
|
|
components={mdxComponents}
|
|
options={mdxOptions as any}
|
|
/>
|
|
</article>
|
|
);
|
|
} |