2024-09-21 19:56:45 -07:00
|
|
|
const esbuild = require("esbuild");
|
2023-06-05 18:33:36 -07:00
|
|
|
|
|
|
|
module.exports = function (eleventyConfig) {
|
2023-06-21 12:13:56 -07:00
|
|
|
// Process SCSS
|
2024-09-21 19:56:45 -07:00
|
|
|
eleventyConfig.addPlugin(require("eleventy-sass"), {
|
|
|
|
postcss: require("postcss")([
|
|
|
|
require("postcss-preset-env"),
|
|
|
|
require("cssnano"),
|
2023-06-21 12:13:56 -07:00
|
|
|
]),
|
2024-09-21 19:56:45 -07:00
|
|
|
});
|
2023-06-21 12:13:56 -07:00
|
|
|
|
|
|
|
// Add noopener to links
|
2024-09-21 19:56:45 -07:00
|
|
|
eleventyConfig.addPlugin(require("eleventy-plugin-automatic-noopener"), {
|
2023-06-21 12:13:56 -07:00
|
|
|
noreferrer: true,
|
2024-09-21 19:56:45 -07:00
|
|
|
});
|
2023-06-21 12:13:56 -07:00
|
|
|
|
|
|
|
// Copy CSS assets
|
2024-09-21 19:56:45 -07:00
|
|
|
eleventyConfig.addPassthroughCopy("src/style/assets");
|
2023-06-21 12:13:56 -07:00
|
|
|
|
|
|
|
// Copy collections & links
|
2024-09-21 19:56:45 -07:00
|
|
|
eleventyConfig.addPassthroughCopy("src/collections/images/**/*");
|
|
|
|
eleventyConfig.addPassthroughCopy("src/images");
|
|
|
|
|
|
|
|
// start page
|
|
|
|
eleventyConfig.addPassthroughCopy("src/start/index.html");
|
|
|
|
eleventyConfig.addPassthroughCopy("src/start/style.css");
|
|
|
|
eleventyConfig.addPassthroughCopy("src/favicon.png");
|
2023-06-21 12:13:56 -07:00
|
|
|
|
|
|
|
// Process JS
|
2024-09-21 19:56:45 -07:00
|
|
|
eleventyConfig.addTemplateFormats("js");
|
|
|
|
eleventyConfig.addExtension("js", {
|
|
|
|
outputFileExtension: "js",
|
2023-06-21 12:13:56 -07:00
|
|
|
compile: async (content, path) => {
|
2024-09-21 19:56:45 -07:00
|
|
|
if (path !== "./src/js/main.js") {
|
|
|
|
return;
|
2023-06-21 12:13:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return async () => {
|
|
|
|
const output = await esbuild.build({
|
2024-09-21 19:56:45 -07:00
|
|
|
target: "es2020",
|
2023-06-21 12:13:56 -07:00
|
|
|
entryPoints: [path],
|
|
|
|
minify: true,
|
|
|
|
bundle: true,
|
|
|
|
write: false,
|
2024-09-21 19:56:45 -07:00
|
|
|
});
|
2023-06-21 12:13:56 -07:00
|
|
|
|
2024-09-21 19:56:45 -07:00
|
|
|
return output.outputFiles[0].text;
|
|
|
|
};
|
2023-06-21 12:13:56 -07:00
|
|
|
},
|
2024-09-21 19:56:45 -07:00
|
|
|
});
|
2023-06-21 12:13:56 -07:00
|
|
|
|
|
|
|
// Convert img filename to alt text
|
2024-09-21 19:56:45 -07:00
|
|
|
eleventyConfig.addFilter("toAlt", (text) => {
|
|
|
|
const basename = text.split(".");
|
|
|
|
return basename[0].replace(/-/g, " ");
|
|
|
|
});
|
2023-06-21 12:13:56 -07:00
|
|
|
|
|
|
|
// Convert diary date path to slug
|
2024-09-21 19:56:45 -07:00
|
|
|
eleventyConfig.addFilter("datePathSlugify", (path) => {
|
|
|
|
const folders = path.split("/");
|
|
|
|
const file = folders.pop().split(".");
|
|
|
|
return `${folders[3]}/${folders[4]}/${file[0]}`;
|
|
|
|
});
|
2023-06-21 12:13:56 -07:00
|
|
|
|
|
|
|
// RSS
|
2024-09-21 19:56:45 -07:00
|
|
|
eleventyConfig.addPlugin(require("@11ty/eleventy-plugin-rss"));
|
2023-06-21 12:13:56 -07:00
|
|
|
|
2024-09-21 19:56:45 -07:00
|
|
|
return { dir: { input: "src", output: "dist" } };
|
|
|
|
};
|