Feat/wiki #37
No files matched your search
@@ -59,3 +59,37 @@ pre code {
|
||||
padding: 0 !important;
|
||||
border: none !important;
|
||||
}
|
||||
|
||||
/* Shiki / Rehype Pretty Code Block Container */
|
||||
figure[data-rehype-pretty-code-figure] {
|
||||
margin-top: 1.5rem;
|
||||
margin-bottom: 1.5rem;
|
||||
border-radius: 0.75rem;
|
||||
overflow: hidden;
|
||||
border: 1px solid #27272a; /* Tailwind zinc-800 */
|
||||
background-color: #0d1117; /* Dunkler VS-Code Hintergrund */
|
||||
}
|
||||
|
||||
/* Der Titel/Dateiname (falls im MDX angegeben) */
|
||||
div[data-rehype-pretty-code-title] {
|
||||
background-color: #161b22;
|
||||
border-bottom: 1px solid #27272a;
|
||||
padding: 0.5rem 1rem;
|
||||
font-family: monospace;
|
||||
font-size: 0.75rem;
|
||||
color: #8b949e;
|
||||
}
|
||||
|
||||
/* Der eigentliche Code-Bereich */
|
||||
figure[data-rehype-pretty-code-figure] pre {
|
||||
margin: 0 !important;
|
||||
padding: 1rem !important;
|
||||
background-color: transparent !important;
|
||||
overflow-x: auto;
|
||||
font-size: 0.875rem;
|
||||
line-height: 1.7;
|
||||
}
|
||||
|
||||
figure[data-rehype-pretty-code-figure] code {
|
||||
font-family: var(--font-mono, monospace);
|
||||
}
|
||||
@@ -1,9 +1,8 @@
|
||||
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';
|
||||
import rehypePrettyCode from 'rehype-pretty-code';
|
||||
import { Callout, Grid, Card, Steps, Step, InlineCode } from '@/components/mdx-components';
|
||||
|
||||
const mdxOptions = {
|
||||
mdxOptions: {
|
||||
@@ -11,7 +10,7 @@ const mdxOptions = {
|
||||
[
|
||||
rehypePrettyCode,
|
||||
{
|
||||
theme: 'github-dark', // oder 'one-dark-pro', 'nord', etc.
|
||||
theme: 'github-dark',
|
||||
keepBackground: true,
|
||||
},
|
||||
],
|
||||
@@ -20,12 +19,18 @@ const mdxOptions = {
|
||||
};
|
||||
|
||||
const mdxComponents = {
|
||||
// Eigene UI-Komponenten
|
||||
Callout,
|
||||
Grid,
|
||||
Card,
|
||||
Steps,
|
||||
Step,
|
||||
h2: (props: any) => <h2 className="text-2xl font-bold text-white mt-12 mb-4" {...props} />,
|
||||
|
||||
// Custom Typography Überschreibungen
|
||||
code: InlineCode,
|
||||
h1: (props: any) => <h1 className="text-3xl font-bold text-white mt-8 mb-4 border-b border-zinc-800 pb-3" {...props} />,
|
||||
h2: (props: any) => <h2 className="text-2xl font-bold text-white mt-10 mb-4" {...props} />,
|
||||
h3: (props: any) => <h3 className="text-xl font-semibold text-white mt-6 mb-3" {...props} />,
|
||||
};
|
||||
|
||||
type PageProps = {
|
||||
@@ -43,9 +48,14 @@ export default async function Page({ params }: PageProps) {
|
||||
}
|
||||
|
||||
return (
|
||||
<article className="prose prose-invert max-w-none p-6">
|
||||
<h1>{article.title}</h1>
|
||||
{/* Direkte MDX-Rendering-Komponente von Next.js */}
|
||||
<article className="prose prose-invert prose-blue max-w-4xl mx-auto p-6 md:p-12 min-h-screen">
|
||||
<header className="mb-8 border-b border-zinc-800 pb-6">
|
||||
<h1 className="text-4xl font-extrabold text-white mb-2 m-0">{article.title}</h1>
|
||||
{article.updatedAt && (
|
||||
<p className="text-zinc-500 text-sm m-0">Zuletzt aktualisiert: {article.updatedAt}</p>
|
||||
)}
|
||||
</header>
|
||||
|
||||
<MDXRemote
|
||||
source={article.rawContent}
|
||||
components={mdxComponents}
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
import React from 'react';
|
||||
|
||||
// 1. Callout (Info, Warning, Error)
|
||||
export function Callout({ children, type = 'info' }: { children: React.ReactNode, type?: 'info' | 'warning' | 'error' | 'success' }) {
|
||||
// 1. Callouts (Info, Warning, Error, Success)
|
||||
export function Callout({
|
||||
children,
|
||||
type = 'info'
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
type?: 'info' | 'warning' | 'error' | 'success'
|
||||
}) {
|
||||
const variants = {
|
||||
info: "bg-blue-500/10 border-blue-500 text-blue-200",
|
||||
warning: "bg-amber-500/10 border-amber-500 text-amber-200",
|
||||
@@ -11,34 +17,36 @@ export function Callout({ children, type = 'info' }: { children: React.ReactNode
|
||||
|
||||
return (
|
||||
<div className={`p-4 my-6 rounded-xl border-l-4 ${variants[type]}`}>
|
||||
<div className="flex gap-3">
|
||||
<div className="mt-1">
|
||||
{type === 'info' && <svg className="w-5 h-5" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" /></svg>}
|
||||
{type === 'warning' && <svg className="w-5 h-5" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" /></svg>}
|
||||
<div className="flex gap-3 items-start">
|
||||
<div className="mt-0.5 shrink-0">
|
||||
{type === 'info' && <svg className="w-5 h-5 text-blue-400" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" /></svg>}
|
||||
{type === 'warning' && <svg className="w-5 h-5 text-amber-400" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" /></svg>}
|
||||
{type === 'error' && <svg className="w-5 h-5 text-red-400" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" /></svg>}
|
||||
{type === 'success' && <svg className="w-5 h-5 text-emerald-400" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M5 13l4 4L19 7" /></svg>}
|
||||
</div>
|
||||
<div className="text-sm leading-relaxed">{children}</div>
|
||||
<div className="text-sm leading-relaxed [&>p]:m-0">{children}</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// 2. Card Grid (Für Übersichtsseiten)
|
||||
// 2. Grid & Cards
|
||||
export function Grid({ children }: { children: React.ReactNode }) {
|
||||
return <div className="grid grid-cols-1 md:grid-cols-2 gap-4 my-8">{children}</div>;
|
||||
}
|
||||
|
||||
export function Card({ title, href, children }: { title: string, href: string, children: React.ReactNode }) {
|
||||
export function Card({ title, href, children }: { title: string; href: string; children: React.ReactNode }) {
|
||||
return (
|
||||
<a href={href} className="block p-6 bg-zinc-900 border border-zinc-800 rounded-xl hover:border-blue-500 transition-colors group">
|
||||
<a href={href} className="block p-6 bg-zinc-900 border border-zinc-800 rounded-xl hover:border-blue-500 transition-colors group no-underline">
|
||||
<h3 className="text-lg font-bold text-white group-hover:text-blue-400 m-0 mb-2">{title}</h3>
|
||||
<div className="text-zinc-400 text-sm m-0 leading-relaxed">
|
||||
<div className="text-zinc-400 text-sm m-0 leading-relaxed [&>p]:m-0">
|
||||
{children}
|
||||
</div>
|
||||
</a>
|
||||
);
|
||||
}
|
||||
|
||||
// 3. Steps (Für nummerierte Anleitungen)
|
||||
// 3. Steps
|
||||
export function Steps({ children }: { children: React.ReactNode }) {
|
||||
return (
|
||||
<div className="steps-container ml-4 border-l border-zinc-800 pl-8 my-8 space-y-8">
|
||||
@@ -47,39 +55,33 @@ export function Steps({ children }: { children: React.ReactNode }) {
|
||||
);
|
||||
}
|
||||
|
||||
export function Step({ title, children }: { title: string, children: React.ReactNode }) {
|
||||
export function Step({ title, children }: { title: string; children: React.ReactNode }) {
|
||||
return (
|
||||
<div className="relative">
|
||||
<div className="absolute -left-[41px] flex h-5 w-5 items-center justify-center rounded-full bg-zinc-900 border border-zinc-800 text-[10px] font-bold text-white">
|
||||
{/* Die Nummerierung macht CSS automatisch, siehe unten */}
|
||||
</div>
|
||||
<h3 className="text-white font-bold mb-2 mt-0">{title}</h3>
|
||||
<div className="text-zinc-400 text-sm">{children}</div>
|
||||
<div className="absolute -left-[41px] flex h-5 w-5 items-center justify-center rounded-full bg-zinc-900 border border-zinc-800 text-[10px] font-bold text-white" />
|
||||
<h3 className="text-white font-bold mb-2 mt-0 text-base">{title}</h3>
|
||||
<div className="text-zinc-400 text-sm [&>p]:m-0">{children}</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function InlineCode({ children }: { children?: React.ReactNode }) {
|
||||
// Custom Inline Code (verhindert das Erben auf große Codeblöcke)
|
||||
export function InlineCode({ children, className, ...props }: React.HTMLAttributes<HTMLElement>) {
|
||||
// Wenn 'data-theme' oder 'data-language' existiert, kommt das Element aus rehype-pretty-code (Code-Block)
|
||||
const isCodeBlock = props && ('data-theme' in props || 'data-language' in props);
|
||||
|
||||
// Falls es Teil eines großen Codeblocks ist -> normales <code> ohne Inline-Styling rendern
|
||||
if (isCodeBlock || className?.includes('language-')) {
|
||||
return <code className={className} {...props}>{children}</code>;
|
||||
}
|
||||
|
||||
// Ansonsten: Unser schickes Inline-Code-Design anwenden
|
||||
return (
|
||||
<code className="px-1.5 py-0.5 rounded-md bg-zinc-800 text-pink-400 font-mono text-sm border border-zinc-700/50">
|
||||
<code
|
||||
className="px-1.5 py-0.5 rounded-md bg-zinc-800 text-pink-400 font-mono text-sm border border-zinc-700/50 before:content-none after:content-none"
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
</code>
|
||||
);
|
||||
}
|
||||
|
||||
// 2. Code Block (für mehrzeiligen Code)
|
||||
export function PreBlock({ children }: { children?: React.ReactNode }) {
|
||||
return (
|
||||
<div className="relative my-6 overflow-hidden rounded-xl border border-zinc-800 bg-zinc-950">
|
||||
{/* Optionaler Dekorations-Header für den Codeblock */}
|
||||
<div className="flex items-center gap-1.5 bg-zinc-900/80 px-4 py-2 border-b border-zinc-800">
|
||||
<div className="w-2.5 h-2.5 rounded-full bg-red-500/80" />
|
||||
<div className="w-2.5 h-2.5 rounded-full bg-yellow-500/80" />
|
||||
<div className="w-2.5 h-2.5 rounded-full bg-green-500/80" />
|
||||
</div>
|
||||
<pre className="p-4 overflow-x-auto text-sm font-mono text-zinc-200 m-0">
|
||||
{children}
|
||||
</pre>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
---
|
||||
title: Projekt Starten
|
||||
updatedAt: "2026-08-04"
|
||||
---
|
||||
|
||||
# Willkommen im Wiki
|
||||
Willkommen im offiziellen Wiki! Hier findest du alle Informationen zum Projekt.
|
||||
|
||||
<Grid>
|
||||
<Card title="Installation" href="/wiki/installation">
|
||||
@@ -22,7 +23,7 @@ title: Projekt Starten
|
||||
</Step>
|
||||
<Step title="Abhängigkeiten installieren">
|
||||
Führe den Installer aus:
|
||||
`npm install`
|
||||
`pnpm install`
|
||||
</Step>
|
||||
</Steps>
|
||||
|
||||
@@ -38,4 +39,3 @@ title: Projekt Starten
|
||||
function sayHello(name: string): string {
|
||||
return `Hallo, ${name}!`;
|
||||
}
|
||||
```
|
||||
+1
-15
@@ -1,14 +1,6 @@
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import matter from 'gray-matter';
|
||||
import { remark } from 'remark';
|
||||
import html from 'remark-html';
|
||||
import rehypePrettyCode from 'rehype-pretty-code';
|
||||
|
||||
const options = {
|
||||
theme: 'github-dark', // oder 'nord', 'one-dark-pro', etc.
|
||||
keepBackground: true,
|
||||
};
|
||||
|
||||
export type WikiArticle = {
|
||||
slug: string;
|
||||
@@ -24,15 +16,9 @@ export async function getWikiPageBySlug(slug: string): Promise<WikiArticle | nul
|
||||
const fullPath = path.join(wikiDirectory, `${slug}.mdx`);
|
||||
const fileContents = fs.readFileSync(fullPath, "utf-8");
|
||||
|
||||
// read metadata
|
||||
// Metadaten und Inhalt parsen
|
||||
const { data, content } = matter(fileContents);
|
||||
|
||||
// convert markdown in HTML
|
||||
const processedContent = await remark()
|
||||
.use(html)
|
||||
.process(content);
|
||||
const contentHtml = processedContent.toString();
|
||||
|
||||
return {
|
||||
slug,
|
||||
rawContent: content,
|
||||
|
||||
Reference in new issue
Block a user