Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

front-matter

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

front-matter - npm Package Compare versions

Comparing version 1.0.0 to 2.0.0

examples/no-front-matter.md

8

index.js

@@ -21,4 +21,8 @@

if (regex.test(string)) return parse(string)
else return { attributes: {}, body: string }
var lines = string.split(/(\r?\n)/)
if (lines[0] && lines[0].match(/((= yaml =)|(---))/)) {
return parse(string)
} else {
return { attributes: {}, body: string }
}
}

@@ -25,0 +29,0 @@

@@ -11,3 +11,3 @@ {

"license": "MIT",
"version": "1.0.0",
"version": "2.0.0",
"homepage": "https://github.com/jxson/front-matter",

@@ -14,0 +14,0 @@ "bugs": "https://github.com/jxson/front-matter/issues",

@@ -8,7 +8,7 @@

[![build status](https://secure.travis-ci.org/jxson/front-matter.png)](http://travis-ci.org/jxson/front-matter) [![Coverage Status](https://coveralls.io/repos/jxson/front-matter/badge.svg?branch=)](https://coveralls.io/r/jxson/front-matter?branch=) [![Dependency Status](https://david-dm.org/jxson/front-matter.png)](https://david-dm.org/jxson/front-matter)
[![build status](https://secure.travis-ci.org/jxson/front-matter.png)](http://travis-ci.org/jxson/front-matter) [![Coverage Status](https://coveralls.io/repos/jxson/front-matter/badge.svg?branch=master)](https://coveralls.io/r/jxson/front-matter?branch=master) [![Dependency Status](https://david-dm.org/jxson/front-matter.png)](https://david-dm.org/jxson/front-matter)
This modules does not do any IO (file loading or reading), only extracting yaml front matter from strings.
This concept that was originally introduced to me through the [jeykll][jeykll] blogging system and is pretty useful where you want to be able to easily add metadata to content without the need for a database. YAML is extracted from the the top of a file between matching separators of "---" or "= yaml =".
This concept that was originally introduced to me through the [jeykll][jeykll] blogging system and is pretty useful where you want to be able to easily add meta-data to content without the need for a database. YAML is extracted from the the top of a file between matching separators of "---" or "= yaml =".

@@ -34,2 +34,5 @@ <!-- This is part of a long running project I have been working on where I am splitting out internals of [haiku][haiku] into to separate, more useful and shareable modules. If your in need of a static site generator [check it out][haiku]. -->

**NOTE:** As of `front-matter@2.0.0` valid front matter is considered to have
the starting separator on the first line.
Then you can do this:

@@ -36,0 +39,0 @@

@@ -8,3 +8,2 @@

test('var fm = require("front-matter")', function(t) {
var fm = require('../')
t.equal(typeof fm, 'function')

@@ -103,2 +102,12 @@ t.end()

test('fm(string) - no front matter, markdown with hr', function(t) {
read('no-front-matter.md', function(err, data) {
t.error(err, 'read should not error');
var content = fm(data);
t.equal(content.body, data);
t.end()
})
})
test('fm.test(string) - yaml seperator', function(t) {

@@ -105,0 +114,0 @@ read('yaml-seperator.md', function(err, data) {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc