5.0.0 • Published 10 years ago

transform-yaml-markdown v5.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
10 years ago

transform-yaml-markdown version build

transform a folder of markdown files with yaml frontmatter to html

Installation

npm i transform-yaml-markdown

Usage

transform-yaml-markdown <source> <destination> [render] [postRender]

The render and postRender functions should be exported as common.js functions.

render gets a data object passed with the meta data and raw markdown from the current file, a collection of all other files in the current directory and a collection of all files. It should return a Promise that fulfills with the rendered HTML.

example: render.js

module.exports = function(currentFile, filesInCurrentFolder, allFiles) {
  return Promise.resolve(
    '<code>'
      +JSON.stringify(currentFile, null, 2)+' of '+allFiles.length
      +'\n'
      +JSON.stringify(filesInCurrentFolder, null, 2)
    +'</code>'
  );
};

postRender receives a collection of rendered files including a renderedPath property and should also return a Promise that fulfills whenever your post render hook is done.

example: post-render.js

module.exports = function postRender(renderedFiles) {
  console.log('number of rendered files: %i', renderedFiles.length);
  return Promise.resolve(renderedFiles);
};

By default the command tries to load render.js and post-render.js from the current working directory if not specified.

LICENSE

The MIT License (MIT) Maximilian Hoffmann

5.0.0

10 years ago

4.0.0

10 years ago

3.1.0

10 years ago

3.0.1

10 years ago

3.0.0

10 years ago

2.0.0

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago