2021-12-08 01:46:11 +00:00
|
|
|
// const { DateTime } = require("luxon");
|
2021-09-03 02:05:52 +00:00
|
|
|
const pluginRss = require("@11ty/eleventy-plugin-rss");
|
2021-09-16 20:50:21 +00:00
|
|
|
const svgSprite = require("eleventy-plugin-svg-sprite");
|
2023-06-04 15:29:30 +00:00
|
|
|
const dateFilter = require("./src/filters/dateFilter.js");
|
|
|
|
|
const cleanCSS = require("clean-css");
|
2023-10-06 11:16:52 +00:00
|
|
|
//const eleventyWebcPlugin = require("@11ty/eleventy-plugin-webc");
|
|
|
|
|
//const { eleventyImagePlugin } = require("@11ty/eleventy-img");
|
|
|
|
|
const Image = require('@11ty/eleventy-img');
|
2021-09-03 02:05:52 +00:00
|
|
|
|
2021-08-31 02:16:17 +00:00
|
|
|
module.exports = function (config) {
|
2023-06-04 15:29:30 +00:00
|
|
|
config.setServerOptions({
|
|
|
|
|
// Whether the live reload snippet is used
|
|
|
|
|
liveReload: true,
|
|
|
|
|
port: 3456,
|
|
|
|
|
watch: ["dist/**/*.css"],
|
|
|
|
|
showAllHosts: true,
|
|
|
|
|
});
|
2021-09-05 19:30:48 +00:00
|
|
|
// PASSTHROUGHS
|
2023-10-06 11:16:52 +00:00
|
|
|
//config.addPassthroughCopy("src/assets/images/");
|
2021-09-02 01:20:51 +00:00
|
|
|
|
2021-09-05 19:30:48 +00:00
|
|
|
// LAYOUTS //
|
|
|
|
|
config.addLayoutAlias("base", "layouts/base.njk");
|
|
|
|
|
config.addLayoutAlias("post", "layouts/post.njk");
|
2021-09-03 02:05:52 +00:00
|
|
|
|
2021-09-16 20:50:21 +00:00
|
|
|
// FILTERS //
|
2023-06-04 15:29:30 +00:00
|
|
|
// date filter
|
|
|
|
|
config.addFilter("dateFilter", dateFilter);
|
|
|
|
|
// clean and inline CSS
|
|
|
|
|
config.addFilter("cssmin", function (code) {
|
|
|
|
|
return new cleanCSS({}).minify(code).styles;
|
|
|
|
|
});
|
2021-09-16 20:50:21 +00:00
|
|
|
|
2021-09-05 19:30:48 +00:00
|
|
|
// TRANSFORMS //
|
2021-09-16 20:50:21 +00:00
|
|
|
// minify HTML
|
2021-09-03 02:05:52 +00:00
|
|
|
const htmlMinTransform = require("./src/transforms/html-min.js");
|
|
|
|
|
const isProduction = process.env.ELEVENTY_ENV === "production";
|
|
|
|
|
// html min only in production
|
|
|
|
|
if (isProduction) {
|
|
|
|
|
config.addTransform("htmlmin", htmlMinTransform);
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-05 19:30:48 +00:00
|
|
|
// PLUG-INS //
|
2021-09-03 02:05:52 +00:00
|
|
|
config.addPlugin(pluginRss);
|
2021-09-16 20:50:21 +00:00
|
|
|
config.addPlugin(svgSprite, {
|
|
|
|
|
path: "./src/assets/icons",
|
|
|
|
|
svgShortcode: "icon",
|
|
|
|
|
globalClasses: "icon",
|
|
|
|
|
});
|
2023-10-06 11:16:52 +00:00
|
|
|
// WebC
|
|
|
|
|
// config.addPlugin(eleventyWebcPlugin, {
|
|
|
|
|
// components: [
|
|
|
|
|
// // …
|
|
|
|
|
// // Add as a global WebC component
|
|
|
|
|
// "npm:@11ty/eleventy-img/*.webc",
|
|
|
|
|
// ]
|
|
|
|
|
// });
|
|
|
|
|
// Image plugin
|
|
|
|
|
// config.addPlugin(eleventyImagePlugin, {
|
|
|
|
|
// // Set global default options
|
|
|
|
|
// formats: ["webp", "jpeg"],
|
|
|
|
|
// urlPath: "/assets/images/",
|
|
|
|
|
// outputDir: "./dist/assets/images/",
|
|
|
|
|
|
|
|
|
|
// // Notably `outputDir` is resolved automatically
|
|
|
|
|
// // to the project output directory
|
|
|
|
|
|
|
|
|
|
// defaultAttributes: {
|
|
|
|
|
// loading: "lazy",
|
|
|
|
|
// decoding: "async"
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
// SHORTCODES
|
|
|
|
|
config.addShortcode("image", async function(src, cls, alt, sizes) {
|
|
|
|
|
let metadata = await Image(src, {
|
|
|
|
|
widths: [300, 600],
|
|
|
|
|
formats: ["webp", "jpeg"],
|
|
|
|
|
urlPath: "/assets/images/",
|
|
|
|
|
outputDir: "dist/assets/images/",
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
let imageAttributes = {
|
|
|
|
|
class: cls,
|
|
|
|
|
alt,
|
|
|
|
|
sizes,
|
|
|
|
|
loading: "lazy",
|
|
|
|
|
decoding: "async",
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// You bet we throw an error on a missing alt (alt="" works okay)
|
|
|
|
|
return Image.generateHTML(metadata, imageAttributes);
|
|
|
|
|
});
|
2021-09-16 20:50:21 +00:00
|
|
|
|
2021-09-05 19:30:48 +00:00
|
|
|
// EXTRAS //
|
|
|
|
|
// Post List Excerpts
|
|
|
|
|
config.setFrontMatterParsingOptions({
|
|
|
|
|
excerpt: true,
|
|
|
|
|
excerpt_separator: "<!-- excerpt -->",
|
|
|
|
|
});
|
2021-09-03 02:05:52 +00:00
|
|
|
|
2021-09-05 19:30:48 +00:00
|
|
|
// BASE CONFIGURATION //
|
2021-08-31 02:16:17 +00:00
|
|
|
return {
|
|
|
|
|
dir: {
|
|
|
|
|
input: "src",
|
|
|
|
|
output: "dist",
|
|
|
|
|
includes: "includes",
|
|
|
|
|
data: "data",
|
|
|
|
|
},
|
2021-09-03 02:05:52 +00:00
|
|
|
templateFormats: ["html", "njk", "md", "11ty.js"],
|
2021-08-31 02:16:17 +00:00
|
|
|
htmlTemplateEngine: "njk",
|
|
|
|
|
markdownTemplateEngine: "njk",
|
|
|
|
|
};
|
|
|
|
|
};
|