{"id":15685683,"url":"https://github.com/jonschlinkert/parser-front-matter","last_synced_at":"2026-03-16T11:04:21.257Z","repository":{"id":20061301,"uuid":"23329954","full_name":"jonschlinkert/parser-front-matter","owner":"jonschlinkert","description":"Front matter parser that uses gray-matter and bits of real panther, so you know it's good. Kind of like consolidate.js engine, accept it's not an engine, it's a parser. Works with Assemble, express.js, parser-cache, or any application with similar conventions.","archived":false,"fork":false,"pushed_at":"2017-07-16T10:56:07.000Z","size":52,"stargazers_count":9,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-05-01T06:39:26.908Z","etag":null,"topics":["front-matter","gray-matter","handlebars","html","markdown","matter","parser","static-site","static-site-generator","yaml","yaml-frontmatter"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jonschlinkert.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-08-25T21:51:00.000Z","updated_at":"2023-08-06T06:29:27.000Z","dependencies_parsed_at":"2022-09-01T00:22:19.907Z","dependency_job_id":null,"html_url":"https://github.com/jonschlinkert/parser-front-matter","commit_stats":null,"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fparser-front-matter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fparser-front-matter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fparser-front-matter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fparser-front-matter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jonschlinkert","download_url":"https://codeload.github.com/jonschlinkert/parser-front-matter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252926170,"owners_count":21826256,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["front-matter","gray-matter","handlebars","html","markdown","matter","parser","static-site","static-site-generator","yaml","yaml-frontmatter"],"created_at":"2024-10-03T17:28:53.136Z","updated_at":"2026-03-16T11:04:21.183Z","avatar_url":"https://github.com/jonschlinkert.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# parser-front-matter [![NPM version](https://img.shields.io/npm/v/parser-front-matter.svg?style=flat)](https://www.npmjs.com/package/parser-front-matter) [![NPM monthly downloads](https://img.shields.io/npm/dm/parser-front-matter.svg?style=flat)](https://npmjs.org/package/parser-front-matter) [![NPM total downloads](https://img.shields.io/npm/dt/parser-front-matter.svg?style=flat)](https://npmjs.org/package/parser-front-matter) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/parser-front-matter.svg?style=flat\u0026label=Travis)](https://travis-ci.org/jonschlinkert/parser-front-matter)\n\n\u003e Front matter parsing middleware based on gray-matter.\n\n## Install\n\nInstall with [npm](https://www.npmjs.com/):\n\n```sh\n$ npm install --save parser-front-matter\n```\n\nThis is similar to a consolidate.js engine, but for parsing. Works with [assemble](https://github.com/assemble/assemble), [verb](https://github.com/verbose/verb), [generate](https://github.com/generate/generate), [update](https://github.com/update/update), express.js, parser-cache, or any application with similar conventions.\n\n## Usage\n\n```js\nvar parser = require('parser-front-matter');\n```\n\n## API\n\n### [.parse](index.js#L36)\n\nParse front matter from the given string or the `contents` in the given `file` and callback `next(err, file)`.\n\nIf an object is passed, either `file.contents` or `file.content`\nmay be used (for gulp and assemble compatibility).\n\n**Params**\n\n* `file` **{String|Object}**: The object or string to parse.\n* `options` **{Object|Function}**: or `next` callback function. Options are passed to [gray-matter](https://github.com/jonschlinkert/gray-matter).\n* `next` **{Function}**: callback function.\n\n**Example**\n\n```js\n// pass a string\nparser.parse('---\\ntitle: foo\\n---\\nbar', function (err, file) {\n  //=\u003e {content: 'bar', data: {title: 'foo'}}\n});\n\n// or an object\nvar file = {contents: new Buffer('---\\ntitle: foo\\nbar')};\nparser.parse(file, function(err, res) {\n  //=\u003e {content: 'bar', data: {title: 'foo'}}\n});\n```\n\n### [.parseSync](index.js#L72)\n\nParse front matter from the given string or the `contents` in the given `file`. If an object is passed, either `file.contents` or `file.content` may be used (for gulp and assemble compatibility).\n\n**Params**\n\n* `file` **{String|Object}**: The object or string to parse.\n* `options` **{Object}**: passed to [gray-matter](https://github.com/jonschlinkert/gray-matter).\n\n**Example**\n\n```js\n// pass a string\nvar res = parser.parseSync('---\\ntitle: foo\\n---\\nbar');\n\n// or an object\nvar file = {contents: new Buffer('---\\ntitle: foo\\nbar')};\nvar res = parser.parseSync(file);\n//=\u003e {content: 'bar', data: {title: 'foo'}}\n```\n\n## file object\n\nReturned `file` objects have the following properties (no other properties are modified on the given file):\n\n* `data`: data from parsed front matter\n* `content`: the content string, excluding front-matter (assemble compatibility)\n* `contents`: the content string as a buffer, excluding front-matter\n* `orig`: the original content string with front-matter included\n\n## About\n\n### Related projects\n\n* [gray-matter](https://www.npmjs.com/package/gray-matter): Parse front-matter from a string or file. Fast, reliable and easy to use. Parses YAML… [more](https://github.com/jonschlinkert/gray-matter) | [homepage](https://github.com/jonschlinkert/gray-matter \"Parse front-matter from a string or file. Fast, reliable and easy to use. Parses YAML front matter by default, but also has support for YAML, JSON, TOML or Coffee Front-Matter, with options to set custom delimiters. Used by metalsmith, assemble, verb and \")\n* [parser-cache](https://www.npmjs.com/package/parser-cache): Cache and load parsers, similiar to consolidate.js engines. | [homepage](https://github.com/jonschlinkert/parser-cache \"Cache and load parsers, similiar to consolidate.js engines.\")\n* [parser-csv](https://www.npmjs.com/package/parser-csv): CSV parser, compatible with [parser-cache](https://github.com/jonschlinkert/parser-cache). | [homepage](https://github.com/jonschlinkert/parser-csv \"CSV parser, compatible with [parser-cache].\")\n\n### Contributing\n\nPull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).\n\n### Contributors\n\n| **Commits** | **Contributor** | \n| --- | --- |\n| 69 | [jonschlinkert](https://github.com/jonschlinkert) |\n| 2 | [doowb](https://github.com/doowb) |\n\n### Building docs\n\n_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_\n\nTo generate the readme, run the following command:\n\n```sh\n$ npm install -g verbose/verb#dev verb-generate-readme \u0026\u0026 verb\n```\n\n### Running tests\n\nRunning and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:\n\n```sh\n$ npm install \u0026\u0026 npm test\n```\n\n### Author\n\n**Jon Schlinkert**\n\n* [github/jonschlinkert](https://github.com/jonschlinkert)\n* [twitter/jonschlinkert](https://twitter.com/jonschlinkert)\n\n### License\n\nCopyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert).\nReleased under the [MIT License](LICENSE).\n\n***\n\n_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on July 16, 2017._","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonschlinkert%2Fparser-front-matter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonschlinkert%2Fparser-front-matter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonschlinkert%2Fparser-front-matter/lists"}