Gathering detailed insights and metrics for vfile-matter
Gathering detailed insights and metrics for vfile-matter
Gathering detailed insights and metrics for vfile-matter
Gathering detailed insights and metrics for vfile-matter
utility to parse the YAML front matter in a vfile
npm install vfile-matter
Typescript
Module System
Node Version
NPM Version
99.3
Supply Chain
99.4
Quality
79.2
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Total Downloads
17,270,763
Last Day
50,373
Last Week
249,427
Last Month
1,003,060
Last Year
9,761,464
MIT License
32 Stars
74 Commits
4 Forks
6 Watchers
1 Branches
13 Contributors
Updated on Apr 15, 2025
Minified
Minified + Gzipped
Latest Version
5.0.1
Package Id
vfile-matter@5.0.1
Unpacked Size
13.55 kB
Size
5.16 kB
File Count
9
NPM Version
11.2.0
Node Version
23.9.0
Published on
Mar 19, 2025
Cumulative downloads
Total Downloads
Last Day
51%
50,373
Compared to previous day
Last Week
11.1%
249,427
Compared to previous week
Last Month
0.4%
1,003,060
Compared to previous month
Last Year
80.5%
9,761,464
Compared to previous year
vfile utility parse YAML front matter.
This package parses YAML frontmatter,
when found in a file,
and exposes it as file.data.matter
.
It can optionally strip the frontmatter,
which is useful for languages that do not understand frontmatter,
but stripping can make it harder to deal with languages that do understand it,
such as markdown,
because it messes up positional info of warnings and errors.
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.
When using vfiles with markdown,
you are likely also using remark,
in which case you should use remark-frontmatter
,
instead of
stripping frontmatter.
This package is ESM only. In Node.js (version 16+), install with npm:
1npm install vfile-matter
In Deno with esm.sh
:
1import {matter} from 'https://esm.sh/vfile-matter@5'
In browsers with esm.sh
:
1<script type="module"> 2 import {matter} from 'https://esm.sh/vfile-matter@5?bundle' 3</script>
Say our document example.html
contains:
1--- 2layout: solar-system 3--- 4<h1>Jupiter</h1>
…and our module example.js
looks as follows:
1import {read} from 'to-vfile' 2import {matter} from 'vfile-matter' 3 4const file = await read('example.html') 5 6matter(file, {strip: true}) 7 8console.log(file.data) 9console.log(String(file))
…now running node example.js
yields:
1{ matter: { layout: 'solar-system' } }
1<h1>Jupiter</h1>
This package exports the identifier matter
.
It exports the TypeScript types
Options
and
YamlOptions
.
There is no default export.
matter(file[, options])
Parse the YAML front matter in a file and expose it as file.data.matter
.
If no matter is found in the file,
nothing happens,
except that file.data.matter
is set to an empty object ({}
).
If the file value is an Uint8Array
,
assumes it is encoded in UTF-8.
Nothing (undefined
).
Options
Configuration (TypeScript type).
strip
(boolean
, default: false
)
— remove the YAML front matter from the fileyaml
(YamlOptions
, default: {}
)
— configuration for the YAML parser,
passed to yaml
as x
in yaml.parse('', x)
YamlOptions
Options for the YAML parser (TypeScript type).
Equivalent to the combination of
DocumentOptions
,
ParseOptions
,
SchemaOptions
,
and
ToJsOptions
.
1type YamlOptions = DocumentOptions & 2 ParseOptions & 3 SchemaOptions & 4 ToJsOptions
To type file.data.matter
with TypeScript,
you can augment DataMap
from vfile
as follows:
1declare module 'vfile' { 2 interface DataMap { 3 matter: { 4 // `file.data.matter.string` is typed as `string | undefined`. 5 title?: string | undefined 6 } 7 } 8} 9 10// You may not need this, 11// but it makes sure the file is a module. 12export {}
Projects maintained by the unified collective are compatible with maintained versions of Node.js.
When we cut a new major release,
we drop support for unmaintained versions of Node.
This means we try to keep the current release line,
vfile-matter@5
,
compatible with Node.js 16.
See contributing.md
in vfile/.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.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
16 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 10
Reason
no dangerous workflow patterns detected
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
security policy file detected
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
Found 2/30 approved changesets -- score normalized to 0
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-04-28
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More