Markdown front-matter to JSON parser, simple and stable
npm install md-front-matterThe simplest *.md front-matter to JS object parser for Node
Takes input as a Node Buffer or String
``markdown`
---
title: Hello
slug: home
---Hello world!
and output it as a JS object:
`js`
{
data: {
slug: "home",
title: "Hello",
},
content: 'Hello world!
'
}
`bash`
npm i md-front-matter
`js
import matter from 'md-front-matter';
const markdownContent = fs.readFileSync('./post.md', 'utf-8');
const markdownJSON = matter(markdownContent);
`
This package allows us to parse the frontmatter section and the content section from a content string.
Then we want to open up our index.js file and start importing the packages we will need.
``
import fs from 'fs';
import matter from 'md-front-matter';
import Image from 'next/image';
import Link from 'next/link';
Publishing:
npm version patchnpm publish`