gray-matter icon indicating copy to clipboard operation
gray-matter copied to clipboard

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

Open heyAyushh opened this issue 3 years ago • 1 comments

  const md = matter(fileContents, { excerpt: true, sections: true })

md.sections type doesn't exist in GrayMatterFile

heyAyushh avatar Jul 11 '21 06:07 heyAyushh

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.

sebagnz avatar Oct 17 '23 10:10 sebagnz