md-front-matter
v1.0.4
Published
Markdown front-matter to JSON parser, simple and stable
Downloads
5,918
Maintainers
Readme
Markdown Front-matter to JS parser
The simplest *.md front-matter to JS object parser for Node
Takes input as a Node Buffer or String
---
title: Hello
slug: home
---
<h1>Hello world!</h1>
and output it as a JS object:
{
data: {
slug: "home",
title: "Hello",
},
content: '<h1>Hello world!</h1>'
}
Installation
npm i md-front-matter
Usage
import matter from 'md-front-matter';
const markdownContent = fs.readFileSync('./post.md', 'utf-8');
const markdownJSON = matter(markdownContent);
Integration with NextJS
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 patch
npm publish