11.0.4 • Published 3 years ago

yaml-markdown-to-html v11.0.4

Weekly downloads
27
License
MIT
Repository
github
Last release
3 years ago

yaml-markdown-to-html version

render a folder of markdown files with yaml front matter to html

Example: transformation example

Installation

yarn add yaml-markdown-to-html --dev
npm i yaml-markdown-to-html --save-dev

Usage

The command line interface accepts three folders:

yaml-markdown-to-html <content> <public> <render>

<content> is the source folder that contains the markdown files to render

<public> is the destination folder that will contain the rendered html files

<render> is the folder, which contains at least a render.js and may contain a post-render.js, as well as other files that are used to render the markdown files to html. By default the CLI will look for a folder with the same name as the argument if omitted.

render/render.js is called once per file and gets an object with its parsed meta data and the raw markdown string, a collection of all other files in the current directory plus index pages of folders in the current directory and a collection of all files. It should return a Promise that fulfills with the rendered HTML.

example: render/render.js

export default async function render(currentFile, filesInCurrentFolder, allFiles) {
  return '<code>'
      +JSON.stringify(currentFile, null, 2)+' of '+allFiles.length
      +'\n'
      +JSON.stringify(filesInCurrentFolder, null, 2)
    +'</code>';
};

render/postRender.js receives a collection of rendered files including a renderedPath property after all files have been rendered and should return a Promise that fulfills whenever it is done.

example: render/post-render.js

export default async function postRender(renderedFiles) {
  console.log('number of rendered files: %i', renderedFiles.length);
  return renderedFiles;
};

LICENSE

The MIT License (MIT) Maximilian Hoffmann

11.0.4

3 years ago

11.0.2

3 years ago

11.0.3

3 years ago

11.0.0

3 years ago

11.0.1

3 years ago

10.1.0

5 years ago

10.0.0

5 years ago

10.0.1

5 years ago

9.1.0

5 years ago

9.0.1

5 years ago

9.0.0

5 years ago

8.0.0

5 years ago

7.2.1

5 years ago

7.2.0

5 years ago

7.1.0

10 years ago

7.0.0

10 years ago

6.1.1

10 years ago

6.1.0

10 years ago

6.0.1

10 years ago

6.0.0

10 years ago

5.0.2

10 years ago

5.0.1

10 years ago