Skip to content

Commit 042d990

Browse files
committed
Rename
1 parent 87e7e5b commit 042d990

File tree

4 files changed

+45
-44
lines changed

4 files changed

+45
-44
lines changed

index.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,21 @@ var yamlParse = require('js-yaml').safeLoad
55
var parse = require('remark-frontmatter/lib/parse')
66
var matters = require('remark-frontmatter/lib/matters')
77

8-
module.exports = frontmatter
8+
module.exports = matter
99

1010
var matterParse = parse(matters('yaml')[0])[1]
1111

12-
function frontmatter(file, options) {
12+
function matter(file, options) {
1313
var strip = (options || {}).strip
1414
var data = file.data
1515
var doc = String(file)
1616
var result = matterParse(mockEat, doc)
1717
var offset
1818

19-
data.frontmatter = {}
19+
data.matter = {}
2020

2121
if (result) {
22-
data.frontmatter = yamlParse(result.value, {filename: file.path})
22+
data.matter = yamlParse(result.value, {filename: file.path})
2323

2424
if (strip) {
2525
offset = result.length

package.json

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
{
2-
"name": "vfile-frontmatter",
2+
"name": "vfile-matter",
33
"version": "0.0.0",
4-
"description": "Parse the YAML frontmatter in a vfile",
4+
"description": "Parse the YAML front matter in a vfile",
55
"license": "MIT",
66
"keywords": [
77
"virtual",
88
"file",
99
"vfile",
1010
"frontmatter",
11+
"matter",
1112
"yaml"
1213
],
13-
"repository": "vfile/vfile-frontmatter",
14-
"bugs": "https://github.com/vfile/vfile-frontmatter/issues",
14+
"repository": "vfile/vfile-matter",
15+
"bugs": "https://github.com/vfile/vfile-matter/issues",
1516
"funding": {
1617
"type": "opencollective",
1718
"url": "https://opencollective.com/unified"

readme.md

+20-20
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# vfile-frontmatter
1+
# vfile-matter
22

33
[![Build][build-badge]][build]
44
[![Coverage][coverage-badge]][coverage]
@@ -8,14 +8,14 @@
88
[![Backers][backers-badge]][collective]
99
[![Chat][chat-badge]][chat]
1010

11-
Parse the YAML frontmatter in a [`vfile`][vfile].
11+
Parse the YAML front matter in a [`vfile`][vfile].
1212

1313
## Install
1414

1515
[npm][]:
1616

1717
```sh
18-
npm install vfile-frontmatter
18+
npm install vfile-matter
1919
```
2020

2121
## Use
@@ -33,11 +33,11 @@ And our script, `example.js`, looks like so:
3333

3434
```js
3535
var vfile = require('to-vfile')
36-
var frontmatter = require('vfile-frontmatter')
36+
var matter = require('vfile-matter')
3737

3838
var file = vfile.readSync('example.html')
3939

40-
frontmatter(file, {strip: true})
40+
matter(file, {strip: true})
4141

4242
console.log(file.data)
4343
console.log(String(file))
@@ -46,7 +46,7 @@ console.log(String(file))
4646
Now, running our script (`node example`) yields:
4747

4848
```js
49-
{ frontmatter: { title: 'Hello, world!' } }
49+
{ matter: { title: 'Hello, world!' } }
5050
```
5151

5252
```html
@@ -55,20 +55,20 @@ Now, running our script (`node example`) yields:
5555

5656
## API
5757

58-
### `frontmatter(file[, options])`
58+
### `matter(file[, options])`
5959

60-
Parse the YAML frontmatter in a [`vfile`][vfile], and add it as
61-
`file.data.frontmatter`.
60+
Parse the YAML front matter in a [`vfile`][vfile], and add it as
61+
`file.data.matter`.
6262

63-
If no frontmatter is found in the file, nothing happens, except that
64-
`file.data.frontmatter` is set to an empty object (`{}`).
63+
If no matter is found in the file, nothing happens, except that
64+
`file.data.matter` is set to an empty object (`{}`).
6565

6666
###### Parameters
6767

6868
* `file` ([`VFile`][vfile])
6969
— Virtual file
7070
* `options.strip` (`boolean`, default: `false`)
71-
— Remove the YAML frontmatter from the file
71+
— Remove the YAML front matter from the file
7272

7373
###### Returns
7474

@@ -90,21 +90,21 @@ abide by its terms.
9090

9191
<!-- Definitions -->
9292

93-
[build-badge]: https://img.shields.io/travis/vfile/vfile-frontmatter.svg
93+
[build-badge]: https://img.shields.io/travis/vfile/vfile-matter.svg
9494

95-
[build]: https://travis-ci.org/vfile/vfile-frontmatter
95+
[build]: https://travis-ci.org/vfile/vfile-matter
9696

97-
[coverage-badge]: https://img.shields.io/codecov/c/github/vfile/vfile-frontmatter.svg
97+
[coverage-badge]: https://img.shields.io/codecov/c/github/vfile/vfile-matter.svg
9898

99-
[coverage]: https://codecov.io/github/vfile/vfile-frontmatter
99+
[coverage]: https://codecov.io/github/vfile/vfile-matter
100100

101-
[downloads-badge]: https://img.shields.io/npm/dm/vfile-frontmatter.svg
101+
[downloads-badge]: https://img.shields.io/npm/dm/vfile-matter.svg
102102

103-
[downloads]: https://www.npmjs.com/package/vfile-frontmatter
103+
[downloads]: https://www.npmjs.com/package/vfile-matter
104104

105-
[size-badge]: https://img.shields.io/bundlephobia/minzip/vfile-frontmatter.svg
105+
[size-badge]: https://img.shields.io/bundlephobia/minzip/vfile-matter.svg
106106

107-
[size]: https://bundlephobia.com/result?p=vfile-frontmatter
107+
[size]: https://bundlephobia.com/result?p=vfile-matter
108108

109109
[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg
110110

test.js

+16-16
Original file line numberDiff line numberDiff line change
@@ -3,39 +3,39 @@
33
var test = require('tape')
44
var buffer = require('is-buffer')
55
var vfile = require('to-vfile')
6-
var frontmatter = require('.')
6+
var matter = require('.')
77

8-
var matter = '---\nkey: value\nlist:\n - 1\n - 2\n---'
8+
var yaml = '---\nkey: value\nlist:\n - 1\n - 2\n---'
99
var doc = 'Here is a document\nMore of the document\nOther lines\n'
10-
var both = matter + '\n' + doc
10+
var both = yaml + '\n' + doc
1111

12-
test('vfile-frontmatter', function(t) {
12+
test('vfile-matter', function(t) {
1313
var file = vfile({contents: both})
1414

15-
t.equal(frontmatter(file), file, 'should return the given file')
15+
t.equal(matter(file), file, 'should return the given file')
1616

1717
t.deepEqual(
1818
file.data,
19-
{frontmatter: {key: 'value', list: [1, 2]}},
19+
{matter: {key: 'value', list: [1, 2]}},
2020
'should add data'
2121
)
2222

23-
file = frontmatter(vfile({contents: doc}))
24-
t.deepEqual(file.data, {frontmatter: {}}, 'should support no frontmatter')
23+
file = matter(vfile({contents: doc}))
24+
t.deepEqual(file.data, {matter: {}}, 'should support no matter')
2525

26-
file = frontmatter(vfile({contents: both}), {strip: true})
27-
t.deepEqual(String(file), doc, 'should strip frontmatter')
26+
file = matter(vfile({contents: both}), {strip: true})
27+
t.deepEqual(String(file), doc, 'should strip matter')
2828

29-
file = frontmatter(vfile({contents: matter}), {strip: true})
30-
t.deepEqual(String(file), '', 'should strip frontmatter completely')
29+
file = matter(vfile({contents: yaml}), {strip: true})
30+
t.deepEqual(String(file), '', 'should strip matter completely')
3131

32-
file = frontmatter(vfile({contents: doc}), {strip: true})
33-
t.deepEqual(String(file), doc, 'should support no frontmatter w/ strip')
32+
file = matter(vfile({contents: doc}), {strip: true})
33+
t.deepEqual(String(file), doc, 'should support no matter w/ strip')
3434

35-
file = frontmatter(vfile({contents: Buffer.from(both)}), {strip: true})
35+
file = matter(vfile({contents: Buffer.from(both)}), {strip: true})
3636
t.ok(buffer(file.contents), 'should supporting buffers')
3737

38-
file = frontmatter(vfile(), {strip: true})
38+
file = matter(vfile(), {strip: true})
3939
t.ok(file.contents === undefined, 'should supporting empties')
4040

4141
t.end()

0 commit comments

Comments
 (0)