ScribeTypisiertes MDX-CMS

Beispiele

Kopierfertige Snippets für typische scribe-cms-Workflows.

Installation

Füge scribe-cms zu jedem Node 20+ Projekt hinzu.

pnpm add scribe-cms zod better-sqlite3

Konfiguration

Definiere Inhaltstypen mit Zod – übersetzbare, strukturelle und relationale Felder.

import { z } from "zod";
import { defineConfig, defineContentType, field } from "scribe-cms";

const blogSchema = z.object({
title: field.translatable(z.string().min(1)),
description: field.translatable(z.string().min(50)),
author: field.relation("author"),
});

const authorSchema = z.object({
name: field.structural(z.string().min(1)),
});

export default defineConfig({
  rootDir: ".",
  locales: ["en", "fr"],
  types: [
    defineContentType({
      id: "blog",
      path: "/blog/{slug}",
      schema: blogSchema,
      slugStrategy: "localized",
    }),
    defineContentType({
      id: "author",
      contentDir: "authors",
      schema: authorSchema,
    }),
  ],
});

Inhaltsdatei

Eine .mdx-Datei pro Dokument — der Dateiname ist der englische Slug.

---
title: "Hallo Welt"
description: "Ein erster Beitrag, der der Welt ausführlich Hallo sagt, weil das Schema fünfzig Zeichen verlangt."
author: jane
publishedAt: "2026-01-15"
---

Der Body ist MDX. Sowohl **Markdown** als auch Komponenten funktionieren.

Runtime

Inhalte mit einem typisierten Client auslesen — auflisten, auflösen und Beziehungen folgen.

import { createScribe } from "scribe-cms/runtime";
import config from "./scribe.config";

const scribe = createScribe(config);

const posts = scribe.blog.list("fr");
const { document } = scribe.blog.resolve("hello-world", "fr");
const author = scribe.blog.related(document!, "author");

CLI

Validiere Inhalte vor Builds und übersetze veraltete Seiten mit Gemini.

scribe validate
scribe translate --locale fr
scribe status
Beispiele · Scribe