Generate todo cover images
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.jsis a pure module: state palette, urgency (0..10 from the page date relative to a reference date), a seeded PRNG from the slug hash, andrenderTodoCoverSvg()that draws a gradient, blurred hue-shifted blobs, a diagonal band, rings and dots onto a 1020x360 canvassrc/routes/(demo)/todos/[slug]/cover.svg/+server.jsprerenders one SVG per todo page viaentries(), so the build containstodos/<slug>/cover.svgnext to each pageTodoCover.sveltenow places that image and overlays the state badge;PostPreviewpasses 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.svgroute - Render the image from
TodoCover, keep the badge - Update CLAUDE.md and the glossary
Read next
