refactor: switched to mdx for better styling
This commit is contained in:
1 parent
5e78869cbf
commit
18f8496af9
6 files changed
+660
-24
No files matched your search
+13
-16
@@ -1,31 +1,28 @@
|
||||
import { getWikiPageBySlug } from '@/lib/wiki';
|
||||
import { notFound } from 'next/navigation';
|
||||
|
||||
import { MDXRemote } from 'next-mdx-remote/rsc';
|
||||
import { Callout } from '@/components/markdown/Callout';
|
||||
|
||||
const components = {
|
||||
Callout,
|
||||
};
|
||||
|
||||
type PageProps = {
|
||||
params: Promise<{
|
||||
slug: string;
|
||||
}>;
|
||||
};
|
||||
|
||||
export default async function Page({ params }: PageProps) { const { slug } = await params;
|
||||
export default async function Page({ params }: PageProps) {
|
||||
const { slug } = await params;
|
||||
const article = await getWikiPageBySlug(slug);
|
||||
|
||||
if (!article) {
|
||||
notFound(); // Zeigt die 404-Seite, wenn z. B. installation.md nicht existiert
|
||||
}
|
||||
|
||||
return (
|
||||
<article className="max-w-3xl mx-auto p-6">
|
||||
<h1 className="text-3xl font-bold mb-2">{article.title}</h1>
|
||||
{article.updatedAt && (
|
||||
<p className="text-sm text-gray-500 mb-6">Stand: {article.updatedAt}</p>
|
||||
)}
|
||||
|
||||
{/* Gerendertes Markdown-HTML anzeigen */}
|
||||
<div
|
||||
className="prose max-w-none"
|
||||
dangerouslySetInnerHTML={{ __html: article.contentHtml }}
|
||||
/>
|
||||
<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={components} />
|
||||
</article>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user