gray-matter
专门解析 md 文件的内容数据
Install
npm install --save gray-matter
Quest Start
Markdown
---
title: Hello
slug: home
---
<h1>Hello world!</h1>
Node
const fs = require("fs");
const matter = require("gray-matter");
const str = fs.readFileSync("example.html", "utf8");
console.log(matter(str));
/**
* output
*/
{
content: '<h1>Hello world!</h1>',
data: {
title: 'Hello',
slug: 'home'
}
}