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
https://github.com/jonschlinkert
MIT License
3.97k stars 138 forks source link

Property 'sections' does not exist on type 'GrayMatterFile<string>'. #126

Open heyAyushh opened 3 years ago

heyAyushh commented 3 years ago
  const md = matter(fileContents, { excerpt: true, sections: true })

md.sections type doesn't exist in GrayMatterFile

sebagnz commented 1 year ago

I have the same issue, did you find any workaround?

I'm just hard parsing it

type Section = {
  key: string
  data: string
  content: string
}

const contentJson = matter(contentMdStr, { excerpt: true, sections: true }) as matter.GrayMatterFile<any> & { sections: Array<Section> }

but there has to be a better approach.