dist | ||
test | ||
ts | ||
.gitignore | ||
.gitlab-ci.yml | ||
package.json | ||
README.md | ||
tslint.json |
smartfm
smartfm handles frontmatter of files
Availabililty
Status for master
Usage
say you have the following markdown file:
---
title: A really awesome article
date: 23-10-2020
type: feature
---
# A Awesome Title
The world is cool. And here is why
* reason 1
* reason 2
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
})