chore: wiki: add API component and add test
This commit is contained in:
1 parent
91dafe6a06
commit
3c3a4e309a
3 files changed
+62
-2
No files matched your search
@@ -4,7 +4,7 @@ import { MDXRemote } from 'next-mdx-remote/rsc';
|
||||
import rehypePrettyCode from 'rehype-pretty-code';
|
||||
import rehypeSlug from 'rehype-slug';
|
||||
import rehypeAutolinkHeadings from 'rehype-autolink-headings';
|
||||
import { Callout, Grid, Card, Steps, Step, InlineCode, CodeBlockContainer } from '@/components/mdx-components';
|
||||
import { Callout, Grid, Card, Steps, Step, InlineCode, CodeBlockContainer, API } from '@/components/mdx-components';
|
||||
|
||||
const mdxOptions = {
|
||||
mdxOptions: {
|
||||
@@ -43,6 +43,7 @@ const mdxComponents = {
|
||||
Card,
|
||||
Steps,
|
||||
Step,
|
||||
API,
|
||||
// Custom Typography Überschreibungen
|
||||
code: InlineCode,
|
||||
pre: CodeBlockContainer,
|
||||
|
||||
@@ -116,4 +116,46 @@ export function CodeBlockContainer({ children, ...props }: React.HTMLAttributes<
|
||||
<pre {...props}>{children}</pre>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function API({
|
||||
method = 'GET',
|
||||
route,
|
||||
children
|
||||
}: {
|
||||
method?: string;
|
||||
route: string;
|
||||
children?: React.ReactNode;
|
||||
}) {
|
||||
const methodUpper = method.toUpperCase();
|
||||
|
||||
// Farben für die verschiedenen HTTP-Methoden
|
||||
const methodStyles: Record<string, string> = {
|
||||
GET: 'bg-emerald-500/10 text-emerald-400 border-emerald-500/30',
|
||||
POST: 'bg-blue-500/10 text-blue-400 border-blue-500/30',
|
||||
PUT: 'bg-amber-500/10 text-amber-400 border-amber-500/30',
|
||||
PATCH: 'bg-orange-500/10 text-orange-400 border-orange-500/30',
|
||||
DELETE: 'bg-rose-500/10 text-rose-400 border-rose-500/30',
|
||||
};
|
||||
|
||||
const badgeStyle = methodStyles[methodUpper] || 'bg-zinc-800 text-zinc-300 border-zinc-700';
|
||||
|
||||
return (
|
||||
<div className="my-6 rounded-xl border border-zinc-800 bg-zinc-900/50 overflow-hidden">
|
||||
{/* Route & Methoden-Header */}
|
||||
<div className="flex items-center gap-3 p-4 bg-zinc-900 border-b border-zinc-800 font-mono text-sm">
|
||||
<span className={`px-2.5 py-1 rounded-md text-xs font-bold border ${badgeStyle}`}>
|
||||
{methodUpper}
|
||||
</span>
|
||||
<span className="text-zinc-200 font-semibold">/api/{route}</span>
|
||||
</div>
|
||||
|
||||
{/* Beschreibung / Inhalt */}
|
||||
{children && (
|
||||
<div className="p-4 text-sm text-zinc-400 leading-relaxed [&>p]:m-0">
|
||||
{children}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
+18
-1
@@ -3,4 +3,21 @@ title: API
|
||||
updatedAt: "2026-08-05"
|
||||
---
|
||||
|
||||
comming soon...
|
||||
<Callout type="warning">
|
||||
Diese Wiki-Seite ist derzeit nur zum Testen da. Bitte Informationen nicht anwenden!
|
||||
</Callout>
|
||||
|
||||
<Callout type="info">
|
||||
Es weder eine Authentifikation noch ein API-Key notwendig.
|
||||
</Callout>
|
||||
|
||||
## API-Endpoints
|
||||
|
||||
### Stream
|
||||
|
||||
<API method="GET" route="stream/currentID">
|
||||
Jetziges angezeigtes Lied abrufen
|
||||
</API>
|
||||
<API method="POST" route="stream/currentID">
|
||||
Lied zum Anzeigen festlegen
|
||||
</API>
|
||||
Reference in new issue
Block a user