42 lines
1.6 KiB
JavaScript
42 lines
1.6 KiB
JavaScript
import path from "node:path";
|
|
import * as sass from "sass";
|
|
import { HtmlBasePlugin } from "@11ty/eleventy";
|
|
|
|
export default function (eleventyConfig) {
|
|
eleventyConfig.addPlugin(HtmlBasePlugin);
|
|
|
|
eleventyConfig.addGlobalData("layout", "default.liquid");
|
|
|
|
eleventyConfig.addPassthroughCopy("assets/images");
|
|
eleventyConfig.addPassthroughCopy("assets/fonts");
|
|
|
|
eleventyConfig.addFilter("rfcdate", function (date) {
|
|
return `${date.getUTCFullYear()}-${(date.getUTCMonth() + 1).toString().padStart(2, "0")}-${date.getUTCDate().toString().padStart(2, "0")} ${date.getUTCHours().toString().padStart(2, "0")}:${date.getUTCMinutes().toString().padStart(2, "0")}:${date.getUTCSeconds().toString().padStart(2, "0")}`
|
|
})
|
|
|
|
// Creates the extension for use
|
|
eleventyConfig.addExtension("scss", {
|
|
outputFileExtension: "css", // optional, default: "html"
|
|
useLayouts: false,
|
|
|
|
// `compile` is called once per .scss file in the input directory
|
|
compile: async function (inputContent, inputPath) {
|
|
let parsed = path.parse(inputPath);
|
|
if (parsed.name.startsWith("_")) { return; }
|
|
let result = sass.compileString(inputContent, {
|
|
loadPaths: [
|
|
parsed.dir || ".",
|
|
this.config.dir.includes
|
|
]
|
|
});
|
|
|
|
this.addDependencies(inputPath, result.loadedUrls);
|
|
|
|
// This is the render function, `data` is the full data cascade
|
|
return async (data) => {
|
|
return result.css;
|
|
};
|
|
},
|
|
});
|
|
eleventyConfig.addTemplateFormats("scss");
|
|
};
|