@menestrel/fields
v0.1.0
Published
Schema builder and shared field types for Menestrel, the CMS for Astro sites
Downloads
88
Maintainers
Readme
@menestrel/fields
The Menestrel content schema, defined in code inside your Astro repo: typed field builders, compilation to a versioned schema definition (canonical JSON + SHA-256 checksum), semantic diffing, and Zod compilation of the values format.
Zero runtime dependency: the Zod compilation receives the z instance as a parameter (the Astro loader passes astro/zod, the server passes its own, tests pass theirs).
import { defineConfig, collection, fields } from '@menestrel/fields';
export default defineConfig({
project: 'dupuy-stores',
locales: { default: 'fr', others: ['en'] },
collections: {
services: collection({
label: 'Services',
slugFrom: 'titre',
fields: {
titre: fields.text({ label: 'Titre', localized: true, required: true }),
prix: fields.number({ label: 'Prix à partir de', unit: '€', min: 0 }),
seo: fields.seo(),
},
}),
},
});Surface
- 15 field types:
text,textarea,richtext,number,boolean,select,date,datetime,image,file,relation,group,repeater,slug,seo. - Versioned definition format (
schema_format), canonicalisation and SHA-256checksum. compileDefinition,validateDefinition,compileValuesSchema(definition, key, z),requiredForLocale,diffDefinitions,applyMigrationOps.- Field path grammar:
parseFieldPath/formatFieldPath/buildJsonPath.
Full field reference: docs.menestrel.dev.
License
MIT
