From 113d0d55ddd0eef00009453329e4aa0590c9c883 Mon Sep 17 00:00:00 2001 From: Ricardo Date: Wed, 18 Feb 2026 11:42:09 +0100 Subject: [PATCH] fix: generate sparkline SVG inline instead of using external service The v1.sparkline.11ty.dev service returns 429 errors. Generate the sparkline polyline SVG at build time and inline it directly. --- blog.njk | 6 +++--- eleventy.config.js | 12 +++++++++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/blog.njk b/blog.njk index ef60589..acd8622 100644 --- a/blog.njk +++ b/blog.njk @@ -11,9 +11,9 @@ permalink: "blog/{% if pagination.pageNumber > 0 %}page/{{ pagination.pageNumber

Blog

- {% set sparklineData = collections.posts | postingFrequency %} - {% if sparklineData %} - Posting frequency over the last 12 months + {% set sparklineSvg = collections.posts | postingFrequency %} + {% if sparklineSvg %} + {{ sparklineSvg | safe }} {% endif %}

diff --git a/eleventy.config.js b/eleventy.config.js index a937c51..8315b69 100644 --- a/eleventy.config.js +++ b/eleventy.config.js @@ -456,7 +456,17 @@ export default function (eleventyConfig) { counts[11 - monthsAgo]++; } } - return counts.join(","); + const max = Math.max(...counts, 1); + const w = 200; + const h = 30; + const pad = 2; + const step = w / (counts.length - 1); + const points = counts.map((v, i) => { + const x = i * step; + const y = h - pad - ((v / max) * (h - pad * 2)); + return `${x.toFixed(1)},${y.toFixed(1)}`; + }).join(" "); + return ``; }); // Collections for different post types