FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Pass both frontmatter and body field for md and mdx content · Issue #106 · contentlayerdev/contentlayer · GitHub

Pass both frontmatter and body field for md and mdx content #106

Description

It seems that contentlayer parses out the fields from md and mdx content and only the body of the content is subsequently passed to markdownToHtml or bundleMDX.

This causes an issue with downstream plugins that rely on the frontmatter properties of the document. Could we pass the entire md/mdx file as the body? Thanks.

For example the following mdx document:

---
title: Sample .md file
date: '2016-03-08'
---

A sample post with markdown.

produces the following mdast from contentlayer (logged at the first task of remarkPlugins):

{
  type: 'root',
  children: [
    { type: 'paragraph', children: [Array], position: [Object] }
  ],
  position: {
    start: { line: 1, column: 1, offset: 0 },
    end: { line: 3, column: 1, offset: 30 }
  }
}

Using mdx-bundler directly gives the following output:

{
  type: 'root',
  children: [
    { type: 'mdxjsEsm', value: '', data: [Object] },
    {
      type: 'yaml',
      value: "title: Sample .md file\ndate: '2016-03-08'",
      position: [Object]
    },
    { type: 'paragraph', children: [Array], position: [Object] }
  ],
  position: {
    start: { line: 1, column: 1, offset: 0 },
    end: { line: 7, column: 1, offset: 89 }
  }
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


    Back | FazBrowse Home | New Git URL