UNPKG

gray-matter-from-file

Version:

Extracts only the front matter from a file stream, and passes to the well known gray-matter library for parsing.

9 lines (6 loc) 297 B
const path = require('path'); const grayMatterFromFile = require('gray-matter-from-file').default; const filepath = path.resolve(__dirname, 'my-file.md'); grayMatterFromFile(filepath) .then(grayMatter => console.log(grayMatter)) // { hello: 'world' } .catch(error => console.log(error))