import { minify } from "terser";
import { transform } from "lightningcss";
import eleventyNavigationPlugin from "@11ty/eleventy-navigation";
import pluginFilters from "./_config/filters.js";

export default function(eleventyConfig) {
    eleventyConfig.addPassthroughCopy("assets/");
	eleventyConfig.addPassthroughCopy({ "sneexy/notebook/": "~sneexy/notebook/" }); // notebook page generated by quartz seperately - see https://forged.synth.download/sneexy/notebook

	// our custom filters
	eleventyConfig.addPlugin(pluginFilters);

	eleventyConfig.addFilter("cssmin", function (code) {
		const result = transform({
			code: Buffer.from(code, 'utf-8'),
			minify: true,
		})
		return result.code.toString('utf-8')
	});

	eleventyConfig.addFilter("jsmin", async function (code) {
		const minified = await minify(code);
		return minified.code;
	});

	eleventyConfig.addPlugin(eleventyNavigationPlugin);
};