{"_id":"zod-matter","_rev":"3-bd6722ab56b98b4d4eea37b6fc8fbcb2","name":"zod-matter","dist-tags":{"latest":"0.1.3"},"versions":{"0.1.0":{"name":"zod-matter","version":"0.1.0","keywords":["markdown","mdx","front-matter","frontmatter","matter","yaml","gray-matter","zod","typescript","typesafe","schema-validation","runtime-validation","type-inference"],"author":{"url":"https://hideoo.dev","name":"HiDeoo","email":"github@hideoo.dev"},"license":"MIT","_id":"zod-matter@0.1.0","maintainers":[{"name":"hideoo","email":"hideo.sup@gmail.com"}],"homepage":"https://github.com/HiDeoo/zod-matter","bugs":{"url":"https://github.com/HiDeoo/zod-matter/issues"},"dist":{"shasum":"00017130ff152f558559a165aa3de192abd9095a","tarball":"https://registry.npmjs.org/zod-matter/-/zod-matter-0.1.0.tgz","fileCount":7,"integrity":"sha512-JpwhZrLOslnIDLCRKkaS4g+rBL7ZDTeX/q/Xx1ngKtMOtNJYVGY0Jdw9YPl2aKZZTcE+sP+B9UxC5MUui+BRnA==","signatures":[{"sig":"MEYCIQDE35BOcBrF/W84VfX6VEZ4q3BlmPWeFRxsuDLGh7XAIwIhAK6hN6cNhZTr9DlBP5vFzKbjuEO1rv49m0F/9KwPKwzH","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13248,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjtvoNACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmo/Sw/9FVKP4gNsa6OvWDW/QVo+oEJJ0c8bRKoRZjtxLMd6ydIZ7lKZ\r\nTZbaXAvqvIRAd1dkOGRKRwoGbA3Nd30j1FkCHNg8b2R35AnC6/TfOKbbvOYV\r\nHXB8nBEt1kBh9g51w5bEv1pxWRBxzqRiTfD79rql1qxVIMiz/7ToavixzFZT\r\nmgZU3AmiyCXrlUFLzsoVlOFYIYYPNCEBJRejNgxl3EtvojeCwTAWYD4GIrxJ\r\nXC/JMqzbpM/4ApQeyKeuS8m94h61coZTD9f3ld5rp8YxZ2LB9Ee84xJjw1E0\r\nFUrPW2JtIIpxHdWHiE83tBuWjylFp8Nd0fY2Bu0gRyFfjlwMPJlWHKwSHmaM\r\nIaeW0bYzPIxSSmR6F1TEgz5KQfzMPW5iIwmIVZAZ0vYtsxuUjKlehKZqxYJx\r\nVOryPxWklT0g7ykv0Or7c20EGiaPY0CXM83aDvhcP7MWu6Ggas7fEwePbxbW\r\nCcPd1Hb0UGLxqq0BxMD9HciII2grr2baQuMUELQi9KOpxa7b63ooMFNoRbH1\r\ncCZuNIVmegapQrHZ2Lzw5uHmcRL6y9D11O1qeBkw6jOg6KPjtOF9JK8RtCN6\r\n04Dvg0vd9mJrxJoqxnDRIwUQbh9TDdSYsCJLeK+uDpPjRu4jwImXqI0Mitcq\r\n7nieDlVg0wyywpsAfD6QbpNSapWeh5Smb1o=\r\n=1Qjo\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./dist/index.cjs","type":"module","_from":"file:zod-matter-0.1.0.tgz","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=18"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"scripts":{"dev":"tsup --watch","lint":"prettier -c . && eslint . --cache --max-warnings=0 && tsc --noEmit","test":"vitest","build":"tsup","test:type":"vitest typecheck"},"_npmUser":{"name":"hideoo","email":"hideo.sup@gmail.com"},"prettier":"@hideoo/prettier-config","_resolved":"/tmp/f89a1a44d5515d85320687fc3fd3ff3e/zod-matter-0.1.0.tgz","_integrity":"sha512-JpwhZrLOslnIDLCRKkaS4g+rBL7ZDTeX/q/Xx1ngKtMOtNJYVGY0Jdw9YPl2aKZZTcE+sP+B9UxC5MUui+BRnA==","repository":{"url":"git+https://github.com/HiDeoo/zod-matter.git","type":"git"},"_npmVersion":"8.19.2","description":"Typesafe front matter","directories":{},"lint-staged":{"**/*":"prettier -w -u --cache","**/*.{js,jsx,ts,tsx,cjs,mjs}":"eslint --cache --max-warnings=0"},"sideEffects":false,"_nodeVersion":"18.12.1","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"packageManager":"pnpm@7.21.0","devDependencies":{"zod":"3.20.2","tsup":"6.5.0","husky":"8.0.3","eslint":"8.31.0","vitest":"0.26.3","prettier":"2.8.1","typescript":"4.9.4","@types/node":"18.11.18","common-tags":"1.8.2","gray-matter":"4.0.3","lint-staged":"13.1.0","@hideoo/tsconfig":"0.1.0","@types/common-tags":"1.8.1","@hideoo/eslint-config":"0.14.1","@hideoo/prettier-config":"0.1.1"},"peerDependencies":{"zod":">=3.0.0","gray-matter":">=3.0.0"},"_npmOperationalInternal":{"tmp":"tmp/zod-matter_0.1.0_1672935949373_0.6592767533015531","host":"s3://npm-registry-packages"}},"0.1.1":{"name":"zod-matter","version":"0.1.1","keywords":["markdown","mdx","front-matter","frontmatter","matter","yaml","gray-matter","zod","typescript","typesafe","schema-validation","runtime-validation","type-inference"],"author":{"url":"https://hideoo.dev","name":"HiDeoo","email":"github@hideoo.dev"},"license":"MIT","_id":"zod-matter@0.1.1","maintainers":[{"name":"hideoo","email":"hideo.sup@gmail.com"}],"homepage":"https://github.com/HiDeoo/zod-matter","bugs":{"url":"https://github.com/HiDeoo/zod-matter/issues"},"dist":{"shasum":"c7df0e5d4829cfa610be6e68a195e48945c90b1d","tarball":"https://registry.npmjs.org/zod-matter/-/zod-matter-0.1.1.tgz","fileCount":7,"integrity":"sha512-+GGjzfWhlFtzok6eV5YR7AS3mDYAFgxwX40B5tqfU00ij/gWpBsXy0qQcFkTxFKMiaGYwkMLpS0ckTWe56Qjsg==","signatures":[{"sig":"MEYCIQDcN2cjoZ7qUMiu/jUIUKy69z/+UhwRMDHFFb28WoqZJAIhAMhGkUTJqJRqVA6Xj/+kbDjbivGVrDLT2rk2kcdcPgqf","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13653,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjtwpVACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqqLw/+KeSAODntPOfaBHpsDl3ToNwquzZaMF1X4EVXxIL5GBFcCnIq\r\nATxY2GCW6t9eubs9wPybYzAUNJFsWA7FmE02t9sWXV/S7Q32dahhUnpcF1zK\r\nD3KCNDggzZellImpUjsgrqEhpXIptYDZrYsDP0iqiQKMaoETX4tpYcMqu13Z\r\nafR6KAVifYTrRxiE958RMlc5m6S6aO/lqsBIbsu23i+/CzeFGbPDzJTgbZ2n\r\nHGi7JGI8EpWy9GjhbwFmWnClq1bENIsh5WjpS0QPxUhIE7w5Qf8C1ZG4a4ha\r\nkhB/hdu6/RVjkzzjv5kDGE3iaTC5OPiSYe7YocaIHKBk7LPGsERPtYHDA0If\r\nTGpHgV+k4IiQ1G1G9OgyMmueTDjqNMtUN5bfefK6HrMF+zJY9wplvK5e0q0v\r\nzLCggAhWQgZTjBf/9cp9emcdC2YTWifIVxAV2W4Kd2eVYybTsKW/n7JVS/xp\r\nc6wgWy3hTE/adhVDKZMMJis0AZSK7QtmAiOFSP21yFE/snUjx6POqeT07R9e\r\npRqQSNVyI2vUKLxMsJdzaIGCfmpV/XwVkLw/RUQS4CHZO78dtLbkNgvzTBkw\r\nnmZvZDgUgxwNhyqPLzn1NcfRi0wXGkD3kY3KNoTaoeh8OfmVyakKTFysZYnx\r\nARu+d7Q7GM69biF9oFwxqX9OUP/+HasRVaI=\r\n=cgeQ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./dist/index.cjs","type":"module","_from":"file:zod-matter-0.1.1.tgz","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=18"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"scripts":{"dev":"tsup --watch","lint":"prettier -c . && eslint . --cache --max-warnings=0 && tsc --noEmit","test":"vitest","build":"tsup","test:type":"vitest typecheck"},"_npmUser":{"name":"hideoo","email":"hideo.sup@gmail.com"},"prettier":"@hideoo/prettier-config","_resolved":"/tmp/486000dcd701078e4be11b8bdb98d0f5/zod-matter-0.1.1.tgz","_integrity":"sha512-+GGjzfWhlFtzok6eV5YR7AS3mDYAFgxwX40B5tqfU00ij/gWpBsXy0qQcFkTxFKMiaGYwkMLpS0ckTWe56Qjsg==","repository":{"url":"git+https://github.com/HiDeoo/zod-matter.git","type":"git"},"_npmVersion":"8.19.2","description":"Typesafe front matter","directories":{},"lint-staged":{"**/*":"prettier -w -u --cache","**/*.{js,jsx,ts,tsx,cjs,mjs}":"eslint --cache --max-warnings=0"},"sideEffects":false,"_nodeVersion":"18.12.1","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"packageManager":"pnpm@7.21.0","devDependencies":{"zod":"3.20.2","tsup":"6.5.0","husky":"8.0.3","eslint":"8.31.0","vitest":"0.26.3","prettier":"2.8.1","typescript":"4.9.4","@types/node":"18.11.18","common-tags":"1.8.2","gray-matter":"4.0.3","lint-staged":"13.1.0","@hideoo/tsconfig":"0.1.0","@types/common-tags":"1.8.1","@hideoo/eslint-config":"0.14.1","@hideoo/prettier-config":"0.1.1"},"peerDependencies":{"zod":">=3.0.0","gray-matter":">=3.0.0"},"_npmOperationalInternal":{"tmp":"tmp/zod-matter_0.1.1_1672940116857_0.6657440313445189","host":"s3://npm-registry-packages"}},"0.1.3":{"name":"zod-matter","version":"0.1.3","license":"MIT","description":"Typesafe front matter","author":{"name":"HiDeoo","email":"github@hideoo.dev","url":"https://hideoo.dev"},"type":"module","main":"./dist/index.cjs","module":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","require":"./dist/index.cjs","import":"./dist/index.js"}},"devDependencies":{"@hideoo/eslint-config":"0.14.1","@hideoo/prettier-config":"0.1.1","@hideoo/tsconfig":"0.1.0","@types/common-tags":"1.8.1","@types/node":"18.11.18","common-tags":"1.8.2","eslint":"8.31.0","gray-matter":"4.0.3","husky":"8.0.3","lint-staged":"13.1.0","prettier":"2.8.1","tsup":"6.5.0","typescript":"4.9.4","vitest":"3.2.4","zod":"3.20.2"},"peerDependencies":{"gray-matter":">=3.0.0","zod":">=3.0.0"},"engines":{"node":">=18"},"publishConfig":{"access":"public"},"sideEffects":false,"keywords":["markdown","mdx","front-matter","frontmatter","matter","yaml","gray-matter","zod","typescript","typesafe","schema-validation","runtime-validation","type-inference"],"homepage":"https://github.com/HiDeoo/zod-matter","repository":{"type":"git","url":"git+https://github.com/HiDeoo/zod-matter.git"},"bugs":{"url":"https://github.com/HiDeoo/zod-matter/issues"},"prettier":"@hideoo/prettier-config","lint-staged":{"**/*":"prettier -w -u --cache","**/*.{js,jsx,ts,tsx,cjs,mjs}":"eslint --cache --max-warnings=0"},"scripts":{"dev":"tsup --watch","build":"tsup","test":"vitest --typecheck","lint":"prettier -c . && eslint . --cache --max-warnings=0 && tsc --noEmit"},"_id":"zod-matter@0.1.3","_integrity":"sha512-Y3zDPxaDL44w3lHPNsxyY24WQyzBP6QBXazoPFl/ahwVKwRnxmYohu1vKokOFfXDjGD5a6XQvh3QlYETdSTvuQ==","_resolved":"/tmp/0c33cc39937e63e25de0b71296e8a1ef/zod-matter-0.1.3.tgz","_from":"file:zod-matter-0.1.3.tgz","_nodeVersion":"24.10.0","_npmVersion":"11.6.1","dist":{"integrity":"sha512-Y3zDPxaDL44w3lHPNsxyY24WQyzBP6QBXazoPFl/ahwVKwRnxmYohu1vKokOFfXDjGD5a6XQvh3QlYETdSTvuQ==","shasum":"2af930c34cf051e0ebc0bcd61e8becdeeed2eca0","tarball":"https://registry.npmjs.org/zod-matter/-/zod-matter-0.1.3.tgz","fileCount":7,"unpackedSize":13592,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/zod-matter@0.1.3","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIF3jhmOCMI/tWbr/wYAjH79jC/xaAfR4lUVjhzTkpBcxAiAG9wrOS0WNpbJHVXlNb2gZM5HAm+R1dkYir5hyp2nmRA=="}]},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:0079a0bf-8ea5-45fd-b8d2-e40df7c23cf2"}},"directories":{},"maintainers":[{"name":"hideoo","email":"hideo.sup@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/zod-matter_0.1.3_1760637284475_0.9374630965346509"},"_hasShrinkwrap":false}},"time":{"created":"2023-01-05T16:25:49.322Z","modified":"2025-10-16T17:54:45.110Z","0.1.0":"2023-01-05T16:25:49.530Z","0.1.1":"2023-01-05T17:35:17.031Z","0.1.3":"2025-10-16T17:54:44.672Z"},"bugs":{"url":"https://github.com/HiDeoo/zod-matter/issues"},"author":{"name":"HiDeoo","email":"github@hideoo.dev","url":"https://hideoo.dev"},"license":"MIT","homepage":"https://github.com/HiDeoo/zod-matter","keywords":["markdown","mdx","front-matter","frontmatter","matter","yaml","gray-matter","zod","typescript","typesafe","schema-validation","runtime-validation","type-inference"],"repository":{"type":"git","url":"git+https://github.com/HiDeoo/zod-matter.git"},"description":"Typesafe front matter","maintainers":[{"name":"hideoo","email":"hideo.sup@gmail.com"}],"readme":"<div align=\"center\">\n  <h1>zod-matter 🏷️</h1>\n  <p>Typesafe front matter</p>\n</div>\n\n<div align=\"center\">\n  <a href=\"https://github.com/HiDeoo/zod-matter/actions/workflows/integration.yml\">\n    <img alt=\"Integration Status\" src=\"https://github.com/HiDeoo/zod-matter/actions/workflows/integration.yml/badge.svg\" />\n  </a>\n  <a href=\"https://github.com/HiDeoo/zod-matter/blob/main/LICENSE\">\n    <img alt=\"License\" src=\"https://badgen.net/github/license/HiDeoo/zod-matter\" />\n  </a>\n  <br />\n</div>\n\n## Features\n\nzod-matter is a tiny wrapper for [gray-matter](https://github.com/jonschlinkert/gray-matter/) and [Zod](https://github.com/colinhacks/zod) to parse and validate front matter with [static type inference](https://www.typescriptlang.org/play?#code/JYWwDg9gTgLgBAbzmAhlAzgUzgXzgMyghDgCIAvCAEwFoQUYZMpSAoUSWROc3AokhWptWAYwgA7dPGASwAV3gBeOAAMaG1ikUALaAC44ACWAARTBAisqDTIYBMABnsBmGo4CM7gKysNNVlYAYmNMABswiDgAd2gwqgBCVlVA8Sl4QkkYAFkGJig4FVQMTAAKVjg4WQUYABoKngA6CAAjACtMURhShAbK7Rg9KENyRukoWQBzUoBKesrKmyYRxqWyub64UVtJ6ABPFfGp2eawGGBJFDDZ+dwZ1nvWTIkcvOZVhhRGgaGnohfcox3ksvms-llAfkPjAvtsmLsoHtAs9XkCoNCvlAUBIqMRWEA).\n\ngray-matter is a great package to parse front matter but provides [no validation or type safety](https://github.com/jonschlinkert/gray-matter/issues/69#issuecomment-454978951). This package exposes an API adding a `schema` parameter to validate front matter data using Zod. This can be particularly useful to parse & validate front matter for user generated Markdown or MDX files for example.\n\n## Installation\n\nInstall `zod-matter` and its peer dependencies with your favorite package manager, e.g.:\n\n```shell\npnpm add zod-matter zod gray-matter\n```\n\n## Usage\n\n### `parse`\n\nExtracts and parses front matter according to the given Zod schema.\n\n```ts\nimport { parse } from 'zod-matter'\nimport { z } from 'zod'\n\nconst { data } = parse('---\\nauthor: HiDeoo\\n---\\n# Hello world!', z.object({ author: z.string() }))\n//       ^? { author: string }\n```\n\n#### Parameters\n\n- `input`: The string, buffer or object with a `content` property to parse.\n- `schema`: The Zod schema to use to parse the front matter.\n- `options`: Optionally, the [gray-matter options](https://github.com/jonschlinkert/gray-matter/tree/a5726b04f3167fadc764241deb545518c454eb82#options) to use.\n\n#### Return value\n\nA file object with the same properties of a [gray-matter file object](https://github.com/jonschlinkert/gray-matter/tree/a5726b04f3167fadc764241deb545518c454eb82#returned-object) but with a `data` property of the type inferred from the given Zod schema.\n\nIf the front matter data is invalid, a [`ZodError`](https://github.com/colinhacks/zod/tree/master#error-handling) will be thrown.\n\n### `read`\n\nExtracts and parses front matter from a file according to the given Zod schema.\n\n```ts\nimport { read } from 'zod-matter'\nimport { z } from 'zod'\n\nconst { data } = read('./data/post.md', z.object({ author: z.string(), date: z.date() }))\n//       ^? { author: string; date: Date }\n```\n\n#### Parameters\n\n- `path`: The path to the file to read and parse.\n- `schema`: The Zod schema to use to parse the front matter.\n- `options`: Optionally, the [gray-matter options](https://github.com/jonschlinkert/gray-matter/tree/a5726b04f3167fadc764241deb545518c454eb82#options) to use.\n\n#### Return value\n\nA file object with the same properties of a [gray-matter file object](https://github.com/jonschlinkert/gray-matter/tree/a5726b04f3167fadc764241deb545518c454eb82#returned-object) but with a `data` property of the type inferred from the given Zod schema.\n\nIf the front matter data is invalid, a [`ZodError`](https://github.com/colinhacks/zod/tree/master#error-handling) will be thrown.\n\n### `stringify`\n\nStringify an object to YAML or a specified language, and append it to the given string.\n\n```ts\nimport { stringify } from 'zod-matter'\nimport { z } from 'zod'\n\nconst content = stringify('# Hello world!', { author: 'HiDeoo' })\n//       ^? ---\n//          author: HiDeoo\n//          ---\n//          # Hello world!\n```\n\nThis function is [re-exported](https://github.com/jonschlinkert/gray-matter/tree/a5726b04f3167fadc764241deb545518c454eb82#stringify) for convenience from gray-matter with the same signature.\n\n### `test`\n\nChecks if the given string contains a front matter.\n\n```ts\nimport { test } from 'zod-matter'\nimport { z } from 'zod'\n\nconst containsFrontMatter = test('---\\nauthor: HiDeoo\\n---\\n# Hello world!')\n//            ^? true\n```\n\nThis function is [re-exported](https://github.com/jonschlinkert/gray-matter/tree/a5726b04f3167fadc764241deb545518c454eb82#test) for convenience from gray-matter with the same signature.\n\n## License\n\nLicensed under the MIT License, Copyright © HiDeoo.\n\nSee [LICENSE](https://github.com/HiDeoo/zod-matter/blob/main/LICENSE) for more information.\n","readmeFilename":"README.md"}