Todo pages have no photo, so the listings showed a gradient rectangle with a state label. It carried the state colour and the urgency tint, but every todo looked the same. The goal: a real picture per todo, stable across builds, without hand-made assets.

Approach

  • src/lib/todo-cover.js is a pure module: state palette, urgency (0..10 from the page date relative to a reference date), a seeded PRNG from the slug hash, and renderTodoCoverSvg() that draws a gradient, blurred hue-shifted blobs, a diagonal band, rings and dots onto a 1020x360 canvas
  • src/routes/(demo)/todos/[slug]/cover.svg/+server.js prerenders one SVG per todo page via entries(), so the build contains todos/<slug>/cover.svg next to each page
  • TodoCover.svelte now places that image and overlays the state badge; PostPreview passes the item link so the component can find the cover
  • Covered by todo-cover.test.js: urgency mapping, colour helpers, determinism per slug

Tasks

  • Move state colours, labels and urgency into a pure module
  • Add the generative renderer and its tests
  • Add the prerendered cover.svg route
  • Render the image from TodoCover, keep the badge
  • Update CLAUDE.md and the glossary

Every todo gets a face

Deterministic art instead of a coloured rectangle

A static site template built with SvelteKit.

Sveleton, 2025