Version 1.0.0
@stackline/remark-frontmatter
remark plugin to support frontmatter (yaml, toml, and more)
Independent maintenance of remark-frontmatter 4.0.1. Original authors and licenses are retained.
Installation
# Preserve existing imports with an npm alias
npm install remark-frontmatter@npm:@stackline/remark-frontmatter@1.0.0
# Or use the scoped package name in your imports
npm install @stackline/remark-frontmatter@1.0.0Node.js: See compatibility notes. Read the compatibility and maintenance notes before migrating.
Usage and API
The reference below may retain upstream package names. Use the alias installation above to run those imports with this Stackline release.
@stackline/remark-frontmatter
Independent maintenance fork of remark-frontmatter@4.0.1, preserving its API and published type declarations.
npm install @stackline/remark-frontmatter
# Keep existing imports:
npm install remark-frontmatter@npm:@stackline/remark-frontmatter@1.0.0
Stackline · Issues · Community
See UPSTREAM.md for source identity and issue review, and CHANGELOG.md for maintenance changes. Functional tests also run against the final npm tarball; releases are published from GitHub Actions with provenance.
Upstream documentation
remark-frontmatter
remark plugin to support frontmatter (YAML, TOML, and more).
Contents
- What is this?
- When should I use this?
- Install
- Use
- API
- Examples
- Syntax
- Syntax tree
- Types
- Compatibility
- Security
- Related
- Contribute
- License
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 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 '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'—Matterdefined as{type: 'yaml', marker: '-'}'toml'—Matterdefined as{type: 'toml', marker: '+'}
Matter
An object with a type and either a marker or a fence:
type(string) — Type to tokenize asmarker(stringor{open: string, close: string}) — Character used to construct fences. By providing an object withopenandclosedifferent characters can be used for opening and closing fences. For example the character'-'will result in'---'being used as the fencefence(stringor{open: string, close: string}) — String used as the complete fence. By providing an object withopenandclosedifferent values can be used for opening and closing fences. This can be used too if fences contain different characters or lengths other than 3anywhere(boolean, default:false) – iftrue, matter can be found anywhere in the document. Iffalse(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
remark-yaml-config— configure remark from YAML configurationremark-gfm— support GFM (autolink literals, strikethrough, tables, tasklists)remark-github— link references to commits, issues, pull-requests, and users, like on GitHubremark-directive— support directivesremark-math— support math
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
Upstream issues and maintenance review
Upstream and maintenance review
Independent maintenance of remark-frontmatter@4.0.1 as @stackline/remark-frontmatter.
- Source history: https://github.com/remarkjs/remark-frontmatter/tree/bb147f9b6a67198a9579735a6e8b2dcd3103a61d
- Original npm integrity:
sha512-38fJrB0KnmD3E33a5jZC/5+gGAC2WKNiPw1/fdXJvijBlhA7RCsvJklrYJakS0HedninvaCYW8lQGf9C918GfA==. - Issues checked: 2026-09-29T00:22:04.858035+00:00.
- Original authors, notices and license are retained. Published runtime and declaration file hashes are recorded in
.stackline/upstream.json; reviewed differences are explicitly listed there. - Original functional suites run against both source and the extracted final tarball. Type checks and the complete development/runtime audit must pass.
Issue triage
The bounded open-issue query returned no issue entries. This is not evidence that the upstream is abandoned or bug-free. No upstream runtime bug fix is claimed.
Historical snapshots were checked against an independently installed exact original npm package before refresh. All fixtures retain differential AST and serialization checks against that original package.
The evidence query fetched the latest 100 open and 30 closed issue/PR entries and removed PRs. This is a bounded review, not a claim of exhaustive issue history or resolution of every issue.
Release verification
GitHub Actions publishes the reviewed passing-CI tarball. Release completion requires exact source identity, zero open CodeQL alerts, npm provenance and tarball identity, normal and aliased installs, and matching immutable GitHub release assets. Existing versions are never replaced.
Release changes
Changelog
1.0.0
- Start Stackline maintenance of the documented upstream API.
- Preserve and verify published runtime files and TypeScript declarations.
- Run upstream functional suites against both source and the final package.
- Publish the reviewed CI artifact through GitHub Actions with provenance and immutable release evidence.
- Refresh historical fixture expectations against the independently installed original npm package under the current locked dependency graph; retain differential coverage for every fixture.
Release files and references
Package bytes, npm provenance and the immutable GitHub release were verified for this version. Security checks describe the reviewed release; documented compatibility risks and upstream reports are not blanket claims of resolution.