Skip to content

v0.0.32

Compare
Choose a tag to compare
@robinmetral robinmetral released this 09 Aug 05:29
80cb5d5

Partials

This release exposes mustache partials, making it easier to compose templates without repeating sections such as site navigation or footer.

To start using partials, add a file to the /partials directory at your project root. The files will be picked up by brut and handed over to mustache at build time. This directory can be configured by setting a partialsDir in brut.config.js.

To reference a partial on a page, use its filename without the extension:

  • /partials/nav.html 👉 {{ > nav }}
  • /partials/footer.whatever 👉 {{ > footer }}
  • /partials/whatever/navitem.html 👉 {{ > navitem }}

Templates breaking change

Previously, template files could be located anywhere in a project, and simply had to be defined in frontmatter using their path from the project root:

  • /templates/base.html 👉 template: /templates/base.html
  • /whatever/article.html 👉 template: /whatever/article.html

Version 0.0.32 introduces a new templates folder. Add your templates to /templates, and they will be picked up by brut at build time. The directory can be configured by setting a partialsDir in brut.config.js.

To define a template path in frontmatter, use its filename without the extension:

  • /templates/base.html 👉 template: base
  • /templates/whatever/article.html 👉 template: article

A major benefit of having templates in a predefined directory is that all templates can be loaded at once at the beginning of the build process, instead of loading them on the fly when a template path was encountered in frontmatter. This reduces the number of filesystem operations and has significant build performance benefits.

Changelog

Full Changelog: v0.0.31...v0.0.32