Exemples

Extraits à copier-coller pour les usages courants de scribe-cms.

Installation

Ajoutez scribe-cms à tout projet Node 20+.

pnpm add scribe-cms zod better-sqlite3

Configuration

Définissez les types de contenu avec Zod — champs traduisibles, structurels et relations.


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,
    }),
  ],
});

Fichier de contenu

Un fichier .mdx par document — le nom de fichier est le slug anglais.

---
title: "Hello, world"
description: "A first post that says hello to the world, at length, because the schema demands fifty characters."
author: jane
publishedAt: "2026-01-15"
---

The body is MDX. **Markdown** and components both work.

Runtime

Lisez le contenu avec un client typé — list, resolve et relations.

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

Validez le contenu avant les builds et traduisez les pages obsolètes avec Gemini.

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