From a330ae2b1c36e647a606433335ecda3e2e350b25 Mon Sep 17 00:00:00 2001 From: Leyla Becker Date: Wed, 11 Feb 2026 17:27:28 -0600 Subject: [PATCH] feat: added socials to bottom of site --- _includes/base.njk | 40 +++++++++++++++++++++++------- assets/forgejo-icon.svg | 1 + assets/mastodon-icon.svg | 3 +++ assets/matrix-icon.svg | 9 +++++++ eleventy.config.js | 53 +++++++++++++++++++++++++++++----------- 5 files changed, 83 insertions(+), 23 deletions(-) create mode 100644 assets/forgejo-icon.svg create mode 100644 assets/mastodon-icon.svg create mode 100644 assets/matrix-icon.svg diff --git a/_includes/base.njk b/_includes/base.njk index 394a3fa..bdd4892 100644 --- a/_includes/base.njk +++ b/_includes/base.njk @@ -34,16 +34,20 @@ h1, h2, h3 { color: var(--primary-color); margin: 1.5rem 0 1rem; } h1 { font-size: 2rem; } footer { margin-top: 2rem; padding-top: 1rem; border-top: 1px solid var(--border-color); text-align: center; color: #666; font-size: 0.9rem; } + footer > div { + display: flex; + justify-content: space-evenly; + } {# Preload full stylesheet with cache-busted filename #} - - + + {# Defer prism.css - only needed for syntax highlighting #} - - - + + +
@@ -58,11 +62,29 @@ \ No newline at end of file diff --git a/assets/forgejo-icon.svg b/assets/forgejo-icon.svg new file mode 100644 index 0000000..b27e891 --- /dev/null +++ b/assets/forgejo-icon.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/assets/mastodon-icon.svg b/assets/mastodon-icon.svg new file mode 100644 index 0000000..e03938c --- /dev/null +++ b/assets/mastodon-icon.svg @@ -0,0 +1,3 @@ + + + diff --git a/assets/matrix-icon.svg b/assets/matrix-icon.svg new file mode 100644 index 0000000..4e5bfb4 --- /dev/null +++ b/assets/matrix-icon.svg @@ -0,0 +1,9 @@ + + + Matrix (protocol) logo + + + + + + diff --git a/eleventy.config.js b/eleventy.config.js index 0726aed..cc45552 100644 --- a/eleventy.config.js +++ b/eleventy.config.js @@ -8,18 +8,19 @@ const crypto = require("crypto"); const path = require("path"); const { DateTime } = require("luxon"); -const cssHashCache = {}; -const getCssHash = (cssFile) => { - if (cssHashCache[cssFile]) return cssHashCache[cssFile]; +const fileHashCache = {}; +const getFileHash = (file, dir = "css") => { + const cacheKey = `${dir}/${file}`; + if (fileHashCache[cacheKey]) return fileHashCache[cacheKey]; - const cssPath = path.join(__dirname, "css", cssFile); + const filePath = path.join(__dirname, dir, file); try { - const content = fs.readFileSync(cssPath, "utf-8"); + const content = fs.readFileSync(filePath, "utf-8"); const hash = crypto.createHash("md5").update(content).digest("hex").slice(0, 8); - cssHashCache[cssFile] = hash; + fileHashCache[cacheKey] = hash; return hash; } catch (e) { - console.warn(`Could not hash CSS file: ${cssFile}`); + console.warn(`Could not hash file: ${file} in ${dir}`); return null; } }; @@ -238,15 +239,16 @@ module.exports = (eleventyConfig) => { return tagMap; }); - // Cache busting filter: returns hashed CSS filename - eleventyConfig.addFilter("cssHash", (cssFile) => { - const hash = getCssHash(cssFile); - const ext = path.extname(cssFile); - const base = path.basename(cssFile, ext); - return `/css/${base}.${hash}${ext}`; + // Cache busting filter: returns hashed filename + eleventyConfig.addFilter("fileHash", (file, dir = "css") => { + const hash = getFileHash(file, dir); + const ext = path.extname(file); + const base = path.basename(file, ext); + return `/${dir}/${base}.${hash}${ext}`; }); eleventyConfig.on("eleventy.before", async () => { + // Copy CSS files with hashes const cssDir = path.join(__dirname, "css"); const outputCssDir = path.join(__dirname, "_site", "css"); @@ -256,7 +258,7 @@ module.exports = (eleventyConfig) => { const cssFiles = fs.readdirSync(cssDir).filter(f => f.endsWith(".css")); for (const cssFile of cssFiles) { - const hash = getCssHash(cssFile); + const hash = getFileHash(cssFile, "css"); const ext = path.extname(cssFile); const base = path.basename(cssFile, ext); const hashedName = `${base}${hash == null ? '' : `.${hash}`}${ext}`; @@ -266,6 +268,29 @@ module.exports = (eleventyConfig) => { path.join(outputCssDir, hashedName) ); } + + // Copy assets files with hashes + const assetsDir = path.join(__dirname, "assets"); + const outputAssetsDir = path.join(__dirname, "_site", "assets"); + + if (fs.existsSync(assetsDir)) { + if (!fs.existsSync(outputAssetsDir)) { + fs.mkdirSync(outputAssetsDir, { recursive: true }); + } + + const assetFiles = fs.readdirSync(assetsDir); + for (const assetFile of assetFiles) { + const hash = getFileHash(assetFile, "assets"); + const ext = path.extname(assetFile); + const base = path.basename(assetFile, ext); + const hashedName = `${base}${hash == null ? '' : `.${hash}`}${ext}`; + + fs.copyFileSync( + path.join(assetsDir, assetFile), + path.join(outputAssetsDir, hashedName) + ); + } + } }); eleventyConfig.addPassthroughCopy("robots.txt");