UNPKG

gray-matter

Version:

A simple to use YAML, JSON or Coffee Front-Matter parsing and extraction library, with options to set custom delimiters.

39 lines (31 loc) 583 B
Let's say our page, `foo.html` contains ```html --- title: YAML Front matter description: This is a page --- <h1>{{title}}</h1> ``` then running the following in the command line: ```js console.log(yfm('foo.html')); ``` returns ```json { "context": { "title": "YAML Front matter", "description": "This is a page" }, "content": "<h1>{{title}}</h1>", "original": "---\ntitle: YAML Front matter\n---\n<h1>{{title}}</h1>" } ``` and ```js console.log(yfm('foo.html').context); ``` returns ```json {"title": "YAML Front matter", "description": "This is a page"} ```