pug-frontmatter-html-loader

Webpack loader for rendering pug to html with frontmatter support.

Usage no npm install needed!

<script type="module">
  import pugFrontmatterHtmlLoader from 'https://cdn.skypack.dev/pug-frontmatter-html-loader';
</script>

README

pug-frontmatter-html-loader

Webpack loader for rendering pug to html with frontmatter support.


npm package version Travis CI build status Coverage Status

About

pug-frontmatter-html-loader is a webpack loader. It renders pug templates to HTML using template data from optional yaml frontmatter parsed with gray-matter.

Simple example pug template with frontmatter:

---
content: "Hello World"
---
p= content

This gives you a convenient way to define more complex template data directly in your template file. As frontmatter usage is optional, this can also be used as a plain pug to html loader.

Installation

pug-frontmatter-html-loader is a public npm package. You can install it using npm:

npm i -D pug-frontmatter-html-loader

Usage

Simply add it as a loader in your webpack config's module rules:

{
  module: {
    rules: [
      {
        test: /\.pug$/,
        use: ['pug-frontmatter-html-loader']
      }
    ]
  }
}

This loader outputs strings. If you want to use them in javascript context, prepend the raw-loader to your loader chain.

Options

See pug compiler options.

License

MIT @ 2018 Simon Lepel