Smarter YAML front matter parser, used by metalsmith, Gatsby, Netlify, Assemble, mapbox-gl, phenomic, vuejs vitepress, TinaCMS, Shopify Polaris, Ant Design, Astro, hashicorp, garden, slidev, saber, sourcegraph, and many others. Simple to use, and battle tested. Parses YAML by default but can also parse JSON Front Matter, Coffee Front Matter, TOML Front Matter, and has support for custom parsers. Please follow gray-matter's author: https://github.com/jonschlinkert
The .matter result property behaves weirdly with caching.
Example:
Welcome to Node.js v21.7.3.
Type ".help" for more information.
> let matter = require('gray-matter');
undefined
> matter('---\ntitle: Title\n---').matter
'\ntitle: Title'
> matter('---\ntitle: Title\n---').matter
undefined
I'm using the .matter property to help map back to precise original source lines (e.g. click in the rendered Markdown to open text editor to right place in source markdown). My workaround right now is to first call matter.clearCache() to always get the .matter property set correctly.
The
.matter
result property behaves weirdly with caching.Example:
I'm using the
.matter
property to help map back to precise original source lines (e.g. click in the rendered Markdown to open text editor to right place in source markdown). My workaround right now is to first callmatter.clearCache()
to always get the.matter
property set correctly.