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 f5a22b777b
3 changed files with 8 additions and 11 deletions

View file

@ -89,7 +89,7 @@ p {
font-size: 12px; font-size: 12px;
--page-width: 1280px; --page-width: 1280px;
--color-text: #495057; --color-text: #495057;
--color-primary: {{ eseColor }}; --color-primary: {{ ese.color }};
--color-livestream-active: #fff; --color-livestream-active: #fff;
--color-background-page: #fefefe; --color-background-page: #fefefe;
--color-background-header: rgba(255,255,255,.92); --color-background-header: rgba(255,255,255,.92);

2
content/_data/ese.yaml Normal file
View file

@ -0,0 +1,2 @@
year: 2024
color: "#F221B7"

View file

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