npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@stackline/remark-frontmatter

v1.0.2

Published

remark plugin to support frontmatter (yaml, toml, and more)

Readme

@stackline/remark-frontmatter

remark plugin to support frontmatter (yaml, toml, and more).

npm version license GitHub repository Docs Reddit community

Documentation | npm | Issues | Repository

Current package version: 1.0.2


Why this package?

@stackline/remark-frontmatter is the Stackline-maintained distribution of [email protected]. It is an independent continuation of remark-frontmatter; original authors and licenses remain credited below.

Compatibility

| Item | Value | | :--- | :--- | | Package | @stackline/[email protected] | | API target | [email protected] | | Supported Node.js | See supported framework requirements | | License | MIT | | Module type | module | | Main entry | index.js | | Types | index.d.ts | | Runtime dependencies | unified, @types/mdast, mdast-util-frontmatter, micromark-extension-frontmatter |

Installation

npm install @stackline/remark-frontmatter

Preserve existing imports and plugin resolution with an npm alias:

npm install remark-frontmatter@npm:@stackline/remark-frontmatter

Usage and API reference

remark-frontmatter

remark plugin to support frontmatter (YAML, TOML, and more).

Contents

What is this?

This package is a unified (remark) plugin to add support for YAML, TOML, and other frontmatter. You can use this to add support for parsing and serializing this syntax extension.

unified is an AST (abstract syntax tree) based transform project. remark is everything unified that relates to markdown. The layer under remark is called mdast, which is only concerned with syntax trees. Another layer underneath is micromark, which is only concerned with parsing. This package is a small wrapper to integrate all of these.

When should I use this?

Frontmatter is a metadata format in front of content. It’s typically written in YAML and is often used with markdown. This mechanism works well when you want authors, that have some markup experience, to configure where or how the content is displayed or supply metadata about content. Frontmatter does not work everywhere so it makes markdown less portable. A good example use case is markdown being rendered by (static) site generators.

Install

This package is ESM only. In Node.js (12.20+, 14.14+, 16.0+), install with npm:

npm install @stackline/remark-frontmatter

In Deno with Skypack:

import remarkFrontmatter from 'https://cdn.skypack.dev/remark-frontmatter@4?dts'

In browsers with Skypack:

<script type="module">
  import remarkFrontmatter from 'https://cdn.skypack.dev/remark-frontmatter@4?min'
</script>

Use

Say we have the following file, example.md:

+++
title = "New Website"
+++

# Other markdown

And our module, example.js, looks as follows:

import {read} from 'to-vfile'
import {unified} from 'unified'
import remarkParse from 'remark-parse'
import remarkFrontmatter from '@stackline/remark-frontmatter'
import remarkStringify from 'remark-stringify'

main()

async function main() {
  const file = await unified()
    .use(remarkParse)
    .use(remarkStringify)
    .use(remarkFrontmatter, ['yaml', 'toml'])
    .use(() => (tree) => {
      console.dir(tree)
    })
    .process(await read('example.md'))

  console.log(String(file))
}

Now, running node example yields:

{
  type: 'root',
  children: [
    {type: 'toml', value: 'title = "New Website"', position: [Object]},
    {type: 'heading', depth: 1, children: [Array], position: [Object]}
  ],
  position: {
    start: {line: 1, column: 1, offset: 0},
    end: {line: 6, column: 1, offset: 48}
  }
}
+++
title = "New Website"
+++

# Other markdown

API

This package exports no identifiers. The default export is remarkFrontmatter.

unified().use(remarkFrontmatter[, options])

Configures remark so that it can parse and serialize frontmatter (YAML, TOML, and more). Doesn’t parse the data inside them: create your own plugin to do that.

options

One preset or Matter, or an array of them, defining all the supported frontmatters (default: 'yaml').

preset

Either 'yaml' or 'toml':

  • 'yaml' — Matter defined as {type: 'yaml', marker: '-'}
  • 'toml' — Matter defined as {type: 'toml', marker: '+'}
Matter

An object with a type and either a marker or a fence:

  • type (string) — Type to tokenize as
  • marker (string or {open: string, close: string}) — Character used to construct fences. By providing an object with open and close different characters can be used for opening and closing fences. For example the character '-' will result in '---' being used as the fence
  • fence (string or {open: string, close: string}) — String used as the complete fence. By providing an object with open and close different values can be used for opening and closing fences. This can be used too if fences contain different characters or lengths other than 3
  • anywhere (boolean, default: false) – if true, matter can be found anywhere in the document. If false (default), only matter at the start of the document is recognized

Examples

Example: custom marker

A custom frontmatter with different open and close markers, repeated 3 times, that looks like this:

<<<
data
>>>

# hi

…can be supported with:

// …
.use(remarkFrontmatter, {type: 'custom', marker: {open: '<', close: '>'}})
// …

Example: custom fence

A custom frontmatter with custom fences that are not repeated like this:

{
  "key": "value"
}

# hi

…can be supported with:

// …
.use(remarkFrontmatter, {type: 'json', fence: {open: '{', close: '}'}})
// …

Syntax

This plugin applies a micromark extensions to parse the syntax. See its readme for how it works:

The syntax supported depends on the given configuration.

Syntax tree

This plugin applies one mdast utility to build and serialize the AST. See its readme for how it works:

The node types supported in the tree depend on the given configuration.

Types

This package is fully typed with TypeScript. The YAML node type is supported in @types/mdast by default. To add other node types, register them by adding them to FrontmatterContentMap:

import type {Literal} from 'mdast'

interface TOML extends Literal {
  type: 'toml'
}

declare module 'mdast' {
  interface FrontmatterContentMap {
    // Allow using toml nodes defined by `remark-frontmatter`.
    toml: TOML
  }
}

Compatibility

Projects maintained by the unified collective are compatible with all maintained versions of Node.js. As of now, that is Node.js 12.20+, 14.14+, and 16.0+. Our projects sometimes work with older versions, but this is not guaranteed.

This plugin works with unified 6+ and remark 13+.

Security

Use of remark-frontmatter does not involve rehype (hast) or user content so there are no openings for cross-site scripting (XSS) attacks.

Related

Contribute

See contributing.md in remarkjs/.github for ways to get started. See support.md for ways to get help.

This project has a code of conduct. By interacting with this repository, organization, or community you agree to abide by its terms.

License

MIT © Titus Wormer

Credits and original authors

Original copyright, license notices and contributor acknowledgements remain part of this distribution. Stackline maintenance does not replace authorship of the original work.

Community and Links

Use this repository's issue tracker for reproducible bugs and feature requests. Join r/Stackline for examples, usage questions and release discussions.