Sphido logo

@sphido/nunjucks

This package allow use nunjucks - a rich and powerful templating language for JavaScript from Mozilla for rendering HTML files from page object.

Functions:

Extenders:

Install

yarn add @sphido/nunjucks

Usage

const globby = require('globby');
const {save} = require('@sphido/nunjucks');
const {getPages} = require('@sphido/core');

(async () => {

    // 1. get list of pages...
    const posts = await getPages(
        await globby('content/**/*.md'),
        ...[
            require('@sphido/frontmatter'),
            require('@sphido/marked'),
            require('@sphido/meta'),
        ],
        {save}
    );

    // 2. save to html with default template
    for await (const page of posts) {
        page.save(
            page.dir.replace('content', 'public')
        );
    }
})();

Source codes

https://github.com/sphido/sphido/tree/master/packages/sphido-nunjucks