UNPKG

next-mdx-remote-client

Version:

A wrapper of the `@mdx-js/mdx` for the `nextjs` applications in order to load MDX content. It is a fork of `next-mdx-remote`.

20 lines 693 B
/** * Copyright (c) @talatkuyuk AKA @ipikuka * SPDX-License-Identifier: MPL-2.0 */ import { VFile } from "vfile"; import { matter } from "vfile-matter"; /** * gets the fronmatter and the stripped source * * @param source markdown or MDX source * @returns fronmatter and stripped source. If no matter is found, the frontmatter is an empty object. */ export function getFrontmatter(source) { const vfile = new VFile(source); matter(vfile, { strip: true }); const frontmatter = vfile.data.matter; // If no matter is found, the file.data.matter is an empty object ({}). return { frontmatter, strippedSource: String(vfile) }; } //# sourceMappingURL=getFrontmatter.js.map