refactor: switched to mdx for better styling

This commit is contained in:
robin committed 2026-08-04 15:32:04 +02:00
1 parent 5e78869cbf
commit 18f8496af9
6 files changed
+660 -24

No files matched your search

+13 -16
View File
@@ -1,31 +1,28 @@
import { getWikiPageBySlug } from '@/lib/wiki'; import { getWikiPageBySlug } from '@/lib/wiki';
import { notFound } from 'next/navigation'; import { notFound } from 'next/navigation';
import { MDXRemote } from 'next-mdx-remote/rsc';
import { Callout } from '@/components/markdown/Callout';
const components = {
Callout,
};
type PageProps = { type PageProps = {
params: Promise<{ params: Promise<{
slug: string; 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); const article = await getWikiPageBySlug(slug);
if (!article) {
notFound(); // Zeigt die 404-Seite, wenn z. B. installation.md nicht existiert
}
return ( return (
<article className="max-w-3xl mx-auto p-6"> <article className="prose prose-invert max-w-none p-6">
<h1 className="text-3xl font-bold mb-2">{article.title}</h1> <h1>{article.title}</h1>
{article.updatedAt && ( {/* Direkte MDX-Rendering-Komponente von Next.js */}
<p className="text-sm text-gray-500 mb-6">Stand: {article.updatedAt}</p> <MDXRemote source={article.rawContent} components={components} />
)}
{/* Gerendertes Markdown-HTML anzeigen */}
<div
className="prose max-w-none"
dangerouslySetInnerHTML={{ __html: article.contentHtml }}
/>
</article> </article>
); );
} }
+11
View File
@@ -0,0 +1,11 @@
export function Callout({ children, type = 'info' }: { children: React.ReactNode; type?: 'info' | 'warning' }) {
const styles = type === 'warning'
? 'bg-amber-500/10 border-amber-500 text-amber-200'
: 'bg-blue-500/10 border-blue-500 text-blue-200';
return (
<div className={`p-4 my-4 rounded-lg border-l-4 ${styles}`}>
{children}
</div>
);
}
@@ -3,10 +3,11 @@ title: Installation & Setup
updatedAt: "2026-08-04" updatedAt: "2026-08-04"
---- ----
> [!WARNING] <Callout type="warning">
> Dieses Projekt befindet sich noch in der aktiven Entwicklungsphase. Bitte verwende es noch nicht für den produktiven Einsatz. Dieses Projekt befindet sich noch in der **aktiven Entwicklungsphase**. Bitte verwende es noch nicht für den produktiven Einsatz.
</Callout>
## Installation # Installation
1. Repository klonen: 1. Repository klonen:
```bash ```bash
@@ -17,7 +18,7 @@ updatedAt: "2026-08-04"
npm install npm install
``` ```
## Setup # Setup
3. Prisma generieren 3. Prisma generieren
```bash ```bash
+3 -3
View File
@@ -7,7 +7,7 @@ import html from 'remark-html';
export type WikiArticle = { export type WikiArticle = {
slug: string; slug: string;
title: string; title: string;
contentHtml: string; rawContent: string;
updatedAt?: string; updatedAt?: string;
}; };
@@ -15,7 +15,7 @@ const wikiDirectory = path.join(process.cwd(), "data/wiki/pages");
export async function getWikiPageBySlug(slug: string): Promise<WikiArticle | null> { export async function getWikiPageBySlug(slug: string): Promise<WikiArticle | null> {
try { try {
const fullPath = path.join(wikiDirectory, `${slug}.md`); const fullPath = path.join(wikiDirectory, `${slug}.mdx`);
const fileContents = fs.readFileSync(fullPath, "utf-8"); const fileContents = fs.readFileSync(fullPath, "utf-8");
// read metadata // read metadata
@@ -29,7 +29,7 @@ export async function getWikiPageBySlug(slug: string): Promise<WikiArticle | nul
return { return {
slug, slug,
contentHtml, rawContent: content,
title: data.title || 'Unbenannt', title: data.title || 'Unbenannt',
updatedAt: data.updatedAt || null, updatedAt: data.updatedAt || null,
...data, ...data,
+6 -1
View File
@@ -13,11 +13,16 @@
"better-sqlite3": "^12.11.1", "better-sqlite3": "^12.11.1",
"gray-matter": "^4.0.3", "gray-matter": "^4.0.3",
"next": "16.2.9", "next": "16.2.9",
"next-mdx-remote": "^6.0.0",
"papaparse": "^5.5.4", "papaparse": "^5.5.4",
"react": "19.2.4", "react": "19.2.4",
"react-dom": "19.2.4", "react-dom": "19.2.4",
"rehype-highlight": "^7.0.2",
"rehype-stringify": "^10.0.1",
"remark": "^15.0.1", "remark": "^15.0.1",
"remark-html": "^16.0.1" "remark-html": "^16.0.1",
"remark-parse": "^11.0.0",
"remark-rehype": "^11.1.2"
}, },
"devDependencies": { "devDependencies": {
"@tailwindcss/postcss": "^4", "@tailwindcss/postcss": "^4",
+622
View File
File diff suppressed because it is too large. Load diff