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

import globby from 'globby';
import {save} from '@sphido/nunjucks';
import {getPages} from '@sphido/core';
import {frontmatter} from '@sphido/frontmatter';
import {markdown} from '@sphido/markdown';
import {meta} from '@sphido/meta';

(async () => {

    // 1. get list of pages...
    const posts = await getPages(
        await globby('content/**/*.md'),
        ...[
            frontmatter,			
            markdown,
            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/main/packages/sphido-nunjucks