Skip to content

umstek/parcel-plugin-md-fm

Repository files navigation

parcel-plugin-md-fm

Parcel plugin for loading markdown with parsed frontmatter.

Install

With npm:

npm install parcel-plugin-md-fm --save-dev

With yarn:

yarn add --dev parcel-plugin-md-fm

Use

Importing:

import { content, data } from "./file.md";

If you get errors or red underlines in editors, add a markdown.d.ts file containing:

declare module "*.md" {
  const content: string;
  const data: object;
}

Test

Tests not implemented yet.

About

This uses the excellent gray-matter library under the hood which separates and then translates yaml or other frontmatter from a markdown file. See jonschlinkert/gray-matter for the exact result format.

Markdown is returned as a string (content) without further parsing so that you can use it with a parser/formatter of your choice like markdown-to-jsx (if you're using react).