Repository navigation
Tags
Tags
Stop minifying builds (#49)
Squashed commit of the following:
commit 7e6dbb88865122254628cea7f8c315e31a5e37d4
Author: Robin Métral <robin@metral.ch>
Date: Wed Dec 10 11:22:32 2025 +0100
Bump version
commit 88157265acc1f2f376003fef2a5e2138d4e8530e
Author: Robin Métral <robin@metral.ch>
Date: Tue Dec 9 21:20:06 2025 +0100
Stop minifying builds
Add support for custom unified plugins (#39) * Upgrade deps fs-extra and html-minifier-terser * Upgrade unified deps and run audit fix audit fix upgraded www subdep axios to 1.7.4 to resolve advisory CVE-2024-39338. Note: this didn't affect brut. * Add rehype-slug plugin * Disable update check in www dev server * Add support for custom remark and rehype plugins * Replace fs-extra with regular fs This also moves types deps to the right package instead of listing them in the workspace package.json * Delete old gitignore * Ignore fs.rm exception when the directory doesn't exist * Bump version
Add permalinks and allow creating custom web feeds (#38) * Remove outdated comment * Generate feed at /feed/ in www using mustache Note: this may not work properly yet, because /feed/ is served as HTML. It should be e.g. feed.xml to optimize compatibility. This will be solved by introducing permalinks. Note 2: the template has to be .html, otherwise it is not picked up by brut. This will be fixed in a follow-up commit. This changes one thing in brut to make it work: pages without a template are now processed with mustache anyway, using their content as the template. This commit changes two unrelated things: - it adds some console.time() to a few parts of the build process - it changes how pages get minified. For now we're still using html-minifier-terser, but only to remove whitespace. This might change (might be removed entirely). * Add permalinks If a page has a permalink value set in frontmatter, its slug is set to that permalink. If a slug ends with a trailing slash, the page is created at /slug/index.html. If not, the page is created at /slug. This allows us to remove a workaround for the 404 page, and enables saving a feed to feed.xml. The "permalink" name, through inaccurate in this case in my opinion, was picked because it's already used by popular generators such as 11ty and Cobalt. This commit also processes .xml files as pages, to make sure they're ran through mustache. Previously, xml feeds had to be saved under a .html extname. * Include title in www template to remove it from web feed content Otherwise, title is duplicated in feed readers. * Fix * Add feed to head * Bump brut version
Pass collection context to mustache (#34) * Build context object from all pages The context is not fed to mustache yet, this will be done in a follow-up commit. This commit also includes cleanup around how paths are determined. There is one minor breaking change: the third attribute that was passed to a custom buildScript, the current page's slug, used to omit the trailing slash. It now includes it, for consistency. * Pass context to mustache BREAKING CHANGE: the mustache view changed from frontmatter `{ [key]: value }` to `{ page: { frontmatter: { [key]: value } }, context: { pages: Page[] } }`. Where a template was referencing the frontmatter `title` via `{{title}}`, it now needs to be referenced as `{{page.frontmatter.title}}`. * Add a config mechanism to preprocess context before it's handed over to the templating engine * Replace custom build script by regular mustache in example site * Add collections Instead of containing all page metadata, context only contains pages that are part of collections. Collections are defined in config and must point to a directory that is a direct descendant of the pagesDir, e.g. `/pages/posts` 👉 `posts`. Collections are based on the path (e.g. pages in `/pages/posts`). To make sure to only include collection pages and not collection indices (e.g. `/pages/posts/index.html`), we check if the page has a `published_date`. The hardcoding of the frontmatter date key is intentional: in a follow-up commit, we can automatically make the published_date a JavaScript Date, to avoid having to do this manually in a processContext script. Inspired by Cobalt. * Add third post to website This is useful for testing sorting by date * Sort collections by date This required another iteration through pages. Any better suggestion to solve this faster is welcome. * Bump version * Update tests to match www changes
Expose mustache partials (#33) * Expose mustache partials - BREAKING: templates now need to be in a configurable templatesDir, /templates by default. Frontmatter should reference templates via the filename, e.g. default.html - mustache partials can be added to a configurable partialsDir, /partials by default. * Update example site template references * Add partial to example site * Add function description * Read templates and partials only once This also strips extensions from templates, they should be referenced as e.g. default and not default.html. This makes it easier to swap one extension for another * Strip template extensions from example site * Bump version