eleventy-mainroad/eleventy.config.js

52 lines
1.7 KiB
JavaScript
Raw Normal View History

2023-05-03 01:18:17 +00:00
const pluginWebc = require("@11ty/eleventy-plugin-webc");
2023-05-03 02:14:30 +00:00
const htmlmin = require("html-minifier");
2023-05-03 01:18:17 +00:00
2023-05-03 02:14:30 +00:00
module.exports = function (ec) {
2023-05-03 01:18:17 +00:00
// Plugins
// add webc files by default
2023-05-03 02:14:30 +00:00
ec.addPlugin(pluginWebc, { components: "_includes/components/**/*.webc" });
ec.addTransform("htmlmin", function (content) {
// Prior to Eleventy 2.0: use this.outputPath instead
if (this.page.outputPath && this.page.outputPath.endsWith(".html")) {
let minified = htmlmin.minify(content, {
useShortDoctype: true,
collapseWhitespace: true,
});
return minified;
}
return content;
});
2023-05-03 01:18:17 +00:00
return {
2023-05-03 02:14:30 +00:00
// Control which files Eleventy will process
// e.g.: *.md, *.njk, *.html, *.liquid
templateFormats: ["md", "njk", "html", "liquid"],
// Pre-process *.md files with: (default: `liquid`)
markdownTemplateEngine: "njk",
// Pre-process *.html files with: (default: `liquid`)
htmlTemplateEngine: "njk",
// These are all optional:
dir: {
input: "content", // default: "."
includes: "../_includes", // default: "_includes"
data: "../_data", // default: "_data"
output: "_site",
},
// -----------------------------------------------------------------
// Optional items:
// -----------------------------------------------------------------
// If your site deploys to a subdirectory, change `pathPrefix`.
// Read more: https://www.11ty.dev/docs/config/#deploy-to-a-subdirectory-with-a-path-prefix
// When paired with the HTML <base> plugin https://www.11ty.dev/docs/plugins/html-base/
// it will transform any absolute URLs in your HTML to include this
// folder name and does **not** affect where things go in the output folder.
pathPrefix: "/",
};
};