From f5a22b777b930c8f9e18764edfedcc9feb0a7db0 Mon Sep 17 00:00:00 2001 From: Lyn Fugmann Date: Thu, 26 Sep 2024 18:23:45 +0200 Subject: [PATCH] move ese year and color to global data file --- _includes/page.css | 2 +- content/_data/ese.yaml | 2 ++ eleventy.config.js | 15 +++++---------- 3 files changed, 8 insertions(+), 11 deletions(-) create mode 100644 content/_data/ese.yaml diff --git a/_includes/page.css b/_includes/page.css index 6310295..e0a0252 100644 --- a/_includes/page.css +++ b/_includes/page.css @@ -89,7 +89,7 @@ p { font-size: 12px; --page-width: 1280px; --color-text: #495057; - --color-primary: {{ eseColor }}; + --color-primary: {{ ese.color }}; --color-livestream-active: #fff; --color-background-page: #fefefe; --color-background-header: rgba(255,255,255,.92); diff --git a/content/_data/ese.yaml b/content/_data/ese.yaml new file mode 100644 index 0000000..89c0a26 --- /dev/null +++ b/content/_data/ese.yaml @@ -0,0 +1,2 @@ +year: 2024 +color: "#F221B7" diff --git a/eleventy.config.js b/eleventy.config.js index 8ce515f..a283991 100644 --- a/eleventy.config.js +++ b/eleventy.config.js @@ -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("{{year}}", String(data.ese.year).slice(-2)); // insert color - svg = svg.replaceAll("{{eseColor}}", data.eseColor); + svg = svg.replaceAll("{{eseColor}}", 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}/`, } };