generate the logo with configured color, year and no embedded text

This commit is contained in:
Lyn Fugmann 2024-09-26 17:47:50 +02:00
parent e31972cb90
commit 324806b52f
6 changed files with 1147 additions and 17 deletions

View file

@ -25,6 +25,36 @@ module.exports = function(eleventyConfig) {
],
});
// process the logo files
eleventyConfig.addTemplateFormats("logo.svg");
eleventyConfig.addExtension("logo.svg", {
outputFileExtension: "svg",
compile: async (inputContent) => {
return async (data) => {
// insert year
let svg = inputContent.replace("{{year}}", String(data.year).slice(-2));
// insert color
svg = svg.replaceAll("{{eseColor}}", data.eseColor);
// render text to path
// TODO replace with ESM import once we switch to Eleventy v3
const Session = (await import('svg-text-to-path')).default;
let session = new Session(svg, {
fonts: {
"Aileron Thin": [{
wght: 400,
source: "./submodules/aileron/fonts/Aileron-Thin.ttf",
}]
}
});
await session.replaceAll();
return session.getSvgString();
};
}
});
eleventyConfig.addDataExtension("yaml, yml", yaml.load);
eleventyConfig.addGlobalData("year", year);