Skip to content

Instantly share code, notes, and snippets.

@maxkorp
Last active May 23, 2017 19:27
Show Gist options
  • Save maxkorp/ac747f6436e3cdc8937b642472dfa752 to your computer and use it in GitHub Desktop.
Save maxkorp/ac747f6436e3cdc8937b642472dfa752 to your computer and use it in GitHub Desktop.
markdown loader that parses out yaml metadata
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