yaml-front-matter
Advanced tools
Comparing version 4.0.0-4 to 4.0.0
@@ -5,2 +5,7 @@ # Change Log | ||
<a name="4.0.0"></a> | ||
# [4.0.0](https://github.com/dworthen/js-yaml-front-matter/compare/v4.0.0-4...v4.0.0) (2018-03-08) | ||
<a name="4.0.0-4"></a> | ||
@@ -7,0 +12,0 @@ # [4.0.0-4](https://github.com/dworthen/js-yaml-front-matter/compare/v4.0.0-3...v4.0.0-4) (2018-02-28) |
@@ -8,5 +8,7 @@ { | ||
"module": "src/index.js", | ||
"version": "4.0.0-4", | ||
"version": "4.0.0", | ||
"keywords": [ | ||
"yaml" | ||
"yaml", | ||
"front matter", | ||
"json" | ||
], | ||
@@ -13,0 +15,0 @@ "repository": { |
@@ -20,3 +20,3 @@ # Yaml Front Matter | ||
name: Derek Worthen | ||
age: young | ||
age: 127 | ||
contact: | ||
@@ -35,8 +35,18 @@ email: email@domain.com | ||
becomes | ||
```js | ||
var fs = require('fs'); | ||
var yamlFront = require('yaml-front-matter'); | ||
fs.readFile('./some/file.txt', 'utf8', function(fileContents) { | ||
console.log(yamlFront.loadFront(fileContents)); | ||
}); | ||
``` | ||
outputs | ||
```js | ||
{ | ||
name: 'Derek Worthen', | ||
age: 'young', | ||
age: 127, | ||
contact: { email: 'email@domain.com', address: 'some location' }, | ||
@@ -68,6 +78,6 @@ pets: [ 'cat', 'dog', 'bat' ], | ||
#### npm | ||
### npm | ||
```shell | ||
$ npm install yaml-front-matter@next | ||
$ npm install yaml-front-matter | ||
``` | ||
@@ -80,10 +90,16 @@ | ||
``` | ||
### Node or client with module bundler (webpack or browsify) | ||
```js | ||
var yamlFront = require('yaml-front-matter'); | ||
``` | ||
#### Browser | ||
### Browser Bundle | ||
Include the client script from [dist/yamlFront.js](dist/yamlFront.js). The library will be exposed as a global, `yamlFront`. The client script for [js-yaml](https://github.com/nodeca/js-yaml) is also required. May need to load espirma for some use cases. See [js-yaml](https://github.com/nodeca/js-yaml) for more information. | ||
The [dist/yamlFront.js](dist/yamlFront.js) client script will expose the yaml-front-matter library as a global, `yamlFront`. The client script for [js-yaml](https://github.com/nodeca/js-yaml) is also required. May need to load espirma for some use cases. See [js-yaml](https://github.com/nodeca/js-yaml) for more information. | ||
```html | ||
<script src="https://unpkg.com/js-yaml@3.10.0/dist/js-yaml.js"></script> | ||
<script src="js-yaml-front-client.min.js"></script> | ||
<script src="yamlFront.js"></script> | ||
<script> | ||
@@ -94,4 +110,6 @@ // parse front matter with yamlFront.loadFront(String); | ||
## Running the Browser Example | ||
> **Note**: yaml-front-matter is delivered as a umd package so it should work within commonjs, amd and browser (as a global) environments. | ||
## Running Browser Example | ||
```shell | ||
@@ -105,3 +123,3 @@ $ npm install --dev && npm start | ||
Outputs client files in `dist/`. | ||
Outputs build files to `dist/`. | ||
@@ -131,4 +149,11 @@ ```shell | ||
> **Note** The cli uses `safeLoadFront` and therefore the cli cannot parse yaml containing regexps, functions or undefined values. | ||
> **Note** The cli uses `safeLoadFront` and therefore will not parse yaml containing regexps, functions or undefined values. | ||
### Example | ||
```shell | ||
# Piping content from one file, through yaml parser and into another file | ||
cat ./some/file.txt | yaml-front-matter > output.txt | ||
``` | ||
## JS-YAML | ||
@@ -143,4 +168,3 @@ | ||
```js | ||
var yamlFront = require('yaml-front-matter') | ||
, input = [ | ||
var input = [ | ||
'---\npost: title one\n', | ||
@@ -158,3 +182,3 @@ 'anArray:\n - one\n - two\n', | ||
the above will produce the following in the console. | ||
outputs | ||
@@ -170,19 +194,14 @@ ```shell | ||
The front-matter is optional. | ||
Front-matter is optional. | ||
``` | ||
frontMatter.loadFront('Hello World'); | ||
``` | ||
Will produce | ||
```js | ||
{ __content: "Hello World!" } | ||
yamlFront.loadFront('Hello World'); | ||
// => { __content: "Hello World!" } | ||
``` | ||
Content all together is optional | ||
Content is optional | ||
```js | ||
frontMatter.loadFront(''); | ||
// will produce { __content: '' } | ||
yamlFront.loadFront(''); | ||
// => { __content: '' } | ||
``` | ||
@@ -192,9 +211,9 @@ | ||
Same api as loadFront except it does not support regexps, functions and undefined. See [js-yaml](https://github.com/nodeca/js-yaml) for more information. | ||
Same api as loadFront except it does not support regexps, functions or undefined. See [js-yaml](https://github.com/nodeca/js-yaml) for more information. | ||
### Options | ||
The options object supports the same options available to [js-yaml](https://github.com/nodeca/js-yaml) except adds support for an additional key. | ||
The options object supports the same options available to [js-yaml](https://github.com/nodeca/js-yaml) and adds support for an additional key. | ||
- `options.contentKeyName`: Specify the object key where the remaining string content after parsing the yaml front-matter will be stored. defaults to `__content`. | ||
- `options.contentKeyName`: Specify the object key where to store content not parsed by yaml-front-matter. defaults to `__content`. | ||
@@ -201,0 +220,0 @@ ```js |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
214475
3
215