jonschlinkert / gray-matter

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

Home Page:https://github.com/jonschlinkert

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Matter instance for global settings. Also, engine.yaml.parse should be optional.

patarapolw opened this issue · comments

It would be nice if I can

import matter from 'gray-matter'
matter.defaults.engines.yaml = {
          stringify: (obj) => yaml.safeDump(obj, { skipInvalid: true }),
          parse: (s) => yaml.safeLoad(s, { schema: yaml.JSON_SCHEMA }),
        }

Actually, I also have one more problem,

matter.stringify(content, {
      ...header, id, date, title, tag,
    }, {
      engines: {
        yaml: {
          stringify: (obj) => yaml.safeDump(obj, { skipInvalid: true }),
          parse: (s) => yaml.safeLoad(s, { schema: yaml.JSON_SCHEMA }),
        },
      },
    })

I cannot omit engine.yaml.parse even if I don't need it.