Skip to content

Commit 4eb3550

Browse files
author
Daihyxsk (Dx)
committed
feat: add Pagefind search and production build minification
Add full-text search via Pagefind with a floating action button (FAB) and modal popup, bilingual FR/EN translations, keyboard shortcut (Ctrl+K). Minify HTML (html-minifier-terser), CSS and JS (esbuild) in production builds for ~35% smaller assets.
1 parent 96e7a2c commit 4eb3550

File tree

7 files changed

+1090
-4
lines changed

7 files changed

+1090
-4
lines changed

.eleventy.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,28 @@
11
// SPDX-License-Identifier: MIT
2+
const htmlmin = require("html-minifier-terser");
3+
4+
const isProd = process.env.NODE_ENV === "production";
5+
26
module.exports = function(eleventyConfig) {
37
eleventyConfig.addPassthroughCopy("src/assets");
48
eleventyConfig.addPassthroughCopy("src/CNAME");
59

10+
if (isProd) {
11+
eleventyConfig.addTransform("htmlmin", async function(content) {
12+
if ((this.page.outputPath || "").endsWith(".html")) {
13+
return await htmlmin.minify(content, {
14+
collapseWhitespace: true,
15+
conservativeCollapse: true,
16+
removeComments: true,
17+
minifyCSS: true,
18+
minifyJS: true,
19+
ignoreCustomFragments: [/<%[\s\S]*?%>/, /<pre[\s\S]*?<\/pre>/]
20+
});
21+
}
22+
return content;
23+
});
24+
}
25+
626
return {
727
dir: {
828
input: "src",

cspell-words.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,11 @@ monorepos
4444
polyrepo
4545
Eleventy
4646
Nunjucks
47+
Pagefind
48+
pagefind
4749
frontmatter
4850
cspell
51+
keydown
4952
husky
5053
pre-commit
5154
rebaser

0 commit comments

Comments
 (0)