{"library":"remark-lint-frontmatter-schema","title":"remark-lint-frontmatter-schema","description":"Validate Markdown frontmatter YAML against an associated JSON schema using remark-lint. Current version: 3.15.4 (released Oct 2023). Released regularly with bug fixes. Key differentiators: supports JSON Schema draft-07, both in-file $schema and global pattern associations, auto-fixes, integration with VS Code and ESLint MDX, and CLI reporting. Uses ajv for validation.","language":"javascript","status":"active","last_verified":"Fri May 01","install":{"commands":["npm install remark-lint-frontmatter-schema"],"cli":null},"imports":["import remarkLintFrontmatterSchema from 'remark-lint-frontmatter-schema'","const plugin = require('remark-lint-frontmatter-schema')","import remarkLintFrontmatterSchema from 'remark-lint-frontmatter-schema'"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { readSync } from 'fs';\nimport { remark } from 'remark';\nimport remarkLint from 'remark-lint';\nimport remarkLintFrontmatterSchema from 'remark-lint-frontmatter-schema';\n\nconst processor = remark()\n  .use(remarkLint)\n  .use(remarkLintFrontmatterSchema, {\n    schemas: [\n      {\n        pattern: '*.md',\n        schema: {\n          type: 'object',\n          properties: {\n            title: { type: 'string' },\n            date: { type: 'string', format: 'date' }\n          },\n          required: ['title', 'date']\n        }\n      }\n    ]\n  });\n\nconst result = processor.processSync(\n  '---\\ntitle: Hello\\ndate: 2023-01-01\\n---\\n# Content'\n);\n\nconsole.log(result.messages);\n// [] (no errors)\n\nconst result2 = processor.processSync(\n  '---\\ntitle: 123\\ndate: not-a-date\\n---\\n# Content'\n);\n\nconsole.log(result2.messages);\n// [ { message: 'title: must be string', ... } ]","lang":"typescript","description":"Set up a remark processor with remark-lint and remark-lint-frontmatter-schema, validate frontmatter against a JSON schema, and see lint messages.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}