Skip to content

feat(feed): site-wide recent-comments feed in Atom and JSON Feed - #239

Merged
KingPin merged 12 commits into
mainfrom
feat/site-recent-feed
Nov 17, 2026
Merged

KingPin merged 12 commits into
mainfrom
feat/site-recent-feed

Conversation

@KingPin

@KingPin KingPin commented Nov 17, 2026

Copy link
Copy Markdown
Owner

Why
Blogs often show a "latest comments" list in a sidebar or footer. Garrul only had per-post feeds, so an operator could not get the newest comments across the site.

This adds GET /feed (Atom) and GET /feed?format=json (JSON Feed 1.1), optionally narrowed to one site with ?site=<origin>. Static sites fetch it at build time and render the list as HTML, so it costs zero Worker requests per pageview. There is deliberately no live widget: a mount on every page would add a Worker request per view.

  • /feed sits outside the /api/* Origin gate, so build steps with no Origin header can fetch it. JSON also sends access-control-allow-origin: *.
  • site must equal an ALLOWED_ORIGINS entry in browser-serialized form, else 400 invalid site. format and site are normalized before the cache key, so junk query strings cannot mint cache entries.
  • 50 newest approved comments, edge-cached 5 minutes. Per-site matching parses posts.url in the Worker, because imported rows can hold non-canonical spellings. The per-site query keeps a unary +c.status, pinned by an EXPLAIN QUERY PLAN test.
  • Comment mutations also drop the site-feed cache entries. Bulk moderation and user erasure drop them once per operation; reactions skip them (no feed change).
  • Fix: /feed/:slug linked to post URLs outside ALLOWED_ORIGINS and built dead anchors like #section&garrul-comment-<id>. Both routes now share one link helper.
  • Docs: a "Recent comments" section in docs/embedding.md, and fail-soft build-time recipes for Astro, Hugo (≥ 0.141) and Jekyll.

No env vars, no migration, no new endpoint under /api/v1.

Linked issue
none

Checks

  • npm run lint
  • npm run typecheck
  • npm test
  • Updated tests for changed behavior (if it touches API contracts, sanitizer, auth, rate-limit, or depth cap)
  • Updated docs (README.md, CLAUDE.md, docs/) if conventions or public behavior changed

@KingPin
KingPin merged commit 8e2d3a3 into main Nov 17, 2026
6 checks passed
@KingPin
KingPin deleted the feat/site-recent-feed branch November 17, 2026 04:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant