Skip to content

get pages frontmatter from remark plugin instead of additional frontmatter package #531

@thescientist13

Description

@thescientist13

Type of Change

  • New Feature Request
  • Documentation / Website
  • Improvement / Suggestion
  • Bug
  • Other (please clarify below)

Summary

Currently there is a secondary plugin needed to extract the frontmatter from a markdown file, in addition the existing remark-frontmatter plugin, which (in theory) should be able to get it for already.

const settings = config.markdown.settings || {};
const fm = frontmatter(markdownContents);  // one plugin

processedMarkdown = await unified()
  .use(remarkParse, settings)
  .use(remarkFrontmatter) // another one here
  .use(remarkPlugins)
  ....
  .process(markdownContents);

if (fm.attributes) {
  // do stuff
}

Details

It would be great to just get everything from processedMarkdown directly, instead of needing a second package just to get the frontmatter. From the docs, this should be possible, but I was having issues when I tried it initially, but hopefully by now we can figure it out. 🤞

Metadata

Metadata

Labels

CLIenhancementImprove something existing (e.g. no docs, new APIs, etc)

Type

Projects

Status

✅ Done

Relationships

None yet

Development

No branches or pull requests

Issue actions