Gathering detailed insights and metrics for @static-pages/yaml-reader
Gathering detailed insights and metrics for @static-pages/yaml-reader
Gathering detailed insights and metrics for @static-pages/yaml-reader
Gathering detailed insights and metrics for @static-pages/yaml-reader
npm install @static-pages/yaml-reader
Typescript
Module System
Node Version
NPM Version
65.8
Supply Chain
81.8
Quality
77.6
Maintenance
100
Vulnerability
80.2
License
JavaScript (58.6%)
TypeScript (41.4%)
Love this project? Help keep it running — sponsor us today! 🚀
Total Downloads
2,239
Last Day
2
Last Week
16
Last Month
40
Last Year
294
30 Commits
1 Watching
1 Branches
Minified
Minified + Gzipped
Latest Version
2.0.1
Package Id
@static-pages/yaml-reader@2.0.1
Unpacked Size
23.45 kB
Size
7.59 kB
File Count
8
NPM Version
8.13.2
Node Version
16.16.0
Cumulative downloads
Total Downloads
Last day
-86.7%
2
Compared to previous day
Last week
0%
16
Compared to previous week
Last month
100%
40
Compared to previous month
Last year
-60.3%
294
Compared to previous year
YAML (and JSON) reader. Reads every file matching a given pattern. Produces an iterable.
JSON files are also supported by this package, since JSON is a subset of the YAML spec.
1import reader from '@static-pages/yaml-reader'; 2 3const iterable = reader({ 4 attrKey: 'attr', 5 cwd: 'pages', 6 pattern: '**/*.yaml', 7 ignore: 'files-to-ignore*', 8 incremental: false, 9}); 10 11// one item in the iterable: 12// { 13// header: { 14// cwd: '/path/to/pages', 15// path: 'folder/file.yaml', 16// dirname: 'folder', 17// basename: 'file', 18// extname: '.yaml' 19// }, 20// attr: { 21// yamlAttribute1: '...', 22// yamlAttribute2: '...', 23// ... 24// } 25// }
reader(options: Options): Iterable<Data>
Options
options.attrKey
(default: empty) file contents will be put under this key in the returned data object to prevent polluting the root (eg. prevent the overwrite of the header field). When left empty the contents are spread into the root object.options.cwd
(default: .
) sets the current working directory.options.pattern
(default: **/*.md
) glob pattern(s) that selects the files to read. Can be a string
or a string
array.options.ignore
(default: undefined
) glob pattern(s) that selects the files to ignore. Can be a string
or a string
array.options.encoding
(default: utf-8
) defines the returned file encoding. Possible values are the same as the encoding
argument of fs.readFile
.options.incremental
(default: false
) enables the incremental reads. See more at @static-pages/file-reader docs page.Data
data.header
contains metadata about the file.
header.cwd
is the absolute path of the cwd
set in the options.header.path
is the file path relative to the header.cwd
.header.dirname
is equivalent to path.dirname(header.path)
.header.basename
is equivalent to path.basename(header.path, header.extname)
.header.extname
is equivalent to path.extname(header.path)
.data.attr
contains attributes defined in the frontmatter style markdown. Property name customizable with options.attrKey
.This module can be used to generate static HTML pages from *.yaml sources. Read more at the Static Pages JS project page.
No vulnerabilities found.
No security vulnerabilities found.