move ese year and color to global data file

This commit is contained in:
Lyn Fugmann 2024-09-26 18:23:45 +02:00
parent 324806b52f
commit 3f5b1988b8
7 changed files with 75 additions and 78 deletions

View file

@ -5,10 +5,6 @@ const pluginIcons = require('eleventy-plugin-icons');
const yaml = require("js-yaml");
const fs = require('fs');
// update this :)
const year = 2024;
const eseColor = "#F221B7";
module.exports = function(eleventyConfig) {
eleventyConfig.addPlugin(EleventyHtmlBasePlugin);
eleventyConfig.addPlugin(eleventyNavigationPlugin);
@ -33,9 +29,9 @@ module.exports = function(eleventyConfig) {
compile: async (inputContent) => {
return async (data) => {
// insert year
let svg = inputContent.replace("{{year}}", String(data.year).slice(-2));
let svg = inputContent.replace("{{ese.year}}", String(data.ese.year).slice(-2));
// insert color
svg = svg.replaceAll("{{eseColor}}", data.eseColor);
svg = svg.replaceAll("{{ese.color}}", data.ese.color);
// render text to path
// TODO replace with ESM import once we switch to Eleventy v3
@ -57,9 +53,6 @@ module.exports = function(eleventyConfig) {
eleventyConfig.addDataExtension("yaml, yml", yaml.load);
eleventyConfig.addGlobalData("year", year);
eleventyConfig.addGlobalData("eseColor", eseColor);
eleventyConfig.addFilter("pageLang", function(value) {
return value.filter(item => item.page.lang === this.page.lang)
});
@ -82,11 +75,13 @@ module.exports = function(eleventyConfig) {
}
);
const eseData = yaml.load(fs.readFileSync('./content/_data/ese.yaml'));
return {
dir: {
input: "content",
includes: "../_includes",
},
pathPrefix: `/${year}/`,
pathPrefix: `/${eseData.year}/`,
}
};