Last active
May 23, 2017 19:27
-
-
Save maxkorp/ac747f6436e3cdc8937b642472dfa752 to your computer and use it in GitHub Desktop.
markdown loader that parses out yaml metadata
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const yamlToJson = require('yaml-to-json'); | |
module.exports = (source) => { | |
this.cacheable(); | |
if (!source.includes('---')) { | |
return { | |
metadata: {}, | |
contents: source | |
}; | |
} | |
const split = source.split('---'); | |
return { | |
metadata: yaml(split[1]), | |
contents: split[2] | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment