Skip to content

Commit

Permalink
Removes minify plugin, adds img plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
mijndert committed Apr 23, 2024
1 parent 5d3d6da commit 84da156
Show file tree
Hide file tree
Showing 3 changed files with 650 additions and 127 deletions.
27 changes: 14 additions & 13 deletions .eleventy.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const dateFilter = require("./src/filters/date-filter.js");
const w3DateFilter = require("./src/filters/w3-date-filter.js");
const pluginRss = require("@11ty/eleventy-plugin-rss");
const embeds = require("eleventy-plugin-embed-everything");
const htmlmin = require("html-minifier");
const { eleventyImagePlugin } = require("@11ty/eleventy-img");

module.exports = (config) => {
config.addFilter("dateFilter", dateFilter);
Expand All @@ -13,18 +13,19 @@ module.exports = (config) => {
config.addPassthroughCopy({ 'src/CNAME': '/CNAME' });
config.addPlugin(pluginRss);
config.addPlugin(embeds);
config.addTransform("htmlmin", function (content) {
if ((this.page.outputPath || "").endsWith(".html")) {
let minified = htmlmin.minify(content, {
useShortDoctype: true,
removeComments: true,
collapseWhitespace: true,
});

return minified;
}
return content;
});
config.addPlugin(eleventyImagePlugin, {
formats: ["avif", "webp", "auto"],
widths: [368, 736, 900],
defaultAttributes: {
sizes: "auto",
loading: "lazy",
decoding: "async",
},
filenameFormat: function (id, src, width, format) {
let filename = path.basename(src, path.extname(src));
return `${filename}-${width}.${format}`;
},
});
return {
markdownTemplateEngine: "njk",
dataTemplateEngine: "njk",
Expand Down
Loading

0 comments on commit 84da156

Please sign in to comment.