md-front-matter
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

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

Package Sidebar

Install

npm i md-front-matter

Weekly Downloads

2,321

Version

1.0.4

License

MIT

Unpacked Size

2.44 kB

Total Files

6

Last publish

Collaborators

  • egavrilov