Ejemplos
Fragmentos listos para copiar de flujos habituales con scribe-cms.
Instalación
Añade scribe-cms a cualquier proyecto con Node 20+.
pnpm add scribe-cms zod better-sqlite3Configuración
Define tipos de contenido con Zod: campos traducibles, estructurales y de relación.
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,
}),
],
});Archivo de contenido
Un archivo .mdx por documento — el nombre del archivo es el slug en inglés.
---
title: "Hola, mundo"
description: "Una primera publicación que saluda al mundo extensamente, porque el esquema exige cincuenta caracteres."
author: jane
publishedAt: "2026-01-15"
---
El cuerpo es MDX. Tanto **Markdown** como los componentes funcionan.Runtime
Lee contenido con un cliente tipado: lista, resuelve y sigue relaciones.
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
Valida el contenido antes de compilar y traduce las páginas desactualizadas con Gemini.
scribe validate
scribe translate --locale fr
scribe status