1.0.4 • Published 11 months ago

md-front-matter v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

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

1.0.4

11 months ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago