Extract frontmatter data from file
Install
npm install to-vfile vfile-matter --save-dev
Extract frontmatter from mdx file
import { readSync } from 'to-vfile';
import { matter } from 'vfile-matter';
const file = readSync(filePath);
matter(file);
console.log(file.data.matter);