Go to file
2017-05-27 23:09:27 +02:00
dist update to latest standards 2017-05-27 23:02:51 +02:00
test update to latest standards 2017-05-27 23:02:51 +02:00
ts update ci 2017-03-11 22:34:28 +01:00
.gitignore initial 2016-11-13 23:11:49 +01:00
.gitlab-ci.yml update ci 2017-03-11 22:34:28 +01:00
npmextra.json add npmextra.json 2017-05-27 23:09:23 +02:00
package.json 1.0.4 2017-05-27 23:09:27 +02:00
README.md improve Readme 2016-11-14 13:33:16 +01:00
tslint.json initial 2016-11-13 23:11:49 +01:00
yarn.lock update to latest standards 2017-05-27 23:02:51 +02:00

smartfm

frontmatter done right

Availabililty

npm git git docs

Status for master

build status coverage report Dependency Status bitHound Dependencies bitHound Code TypeScript node JavaScript Style Guide

What is frontMatter?

say you have the following markdown file:

---
title: A Really Awesome Article
date: 23-10-2020
type: feature
---
# An Awesome Title
The world is cool. And here is why
* reason 1
* reason 2

The top part that is enclosed by --- denotes frontmatter, usually written in yaml notation. Frontmatter is not exclusive to markdown. It can be used as prefix in any type of file when preprocessed with smartfm.

Usage

We recommend TypeScript for best in class Intellisense.

import * as smartfm from * smartfm

let markdownfile = `---
testKey: testValue
testKey2: testValue2
---
# some markdown`

// easy methods
let parsedData = smartfm.parse(markdownfile)

// parsedData will be object
/*
    {
        data: {
            testKey: testValue,
            testKey2: testValue2
        },
        content: '# some markdown',
        orig: '---\ntestKey: testValue\ntestKey2: testValue2\n---\n# some markdown'
    }
*/

let newFmString = smartfm.stringify('My awesome string', {testKey1: testValue1})
// newFmString will be '---\testKey1: testValue1\n---\nMyawesomeString'

# class Smartfm
let mySmartfm = new smartfm.Smartfm({
    fmType: 'yaml' // can be yaml or json atm
})

npm