Skip to content

Add RSS feed for the blog#412

Merged
simonhamp merged 1 commit into
mainfrom
blog-rss-feed
Jul 3, 2026
Merged

Add RSS feed for the blog#412
simonhamp merged 1 commit into
mainfrom
blog-rss-feed

Conversation

@simonhamp

Copy link
Copy Markdown
Member

What

Adds an RSS 2.0 feed for the blog at /blog/feed (route name blog.feed).

  • app/Support/BlogFeed.php — builds the feed with DOMDocument, so the XML is correctly escaped and cleanly indented (declarations for the atom, dc, and media namespaces sit once on the root). XML is data, not markup, so it's generated rather than rendered through a Blade view.
  • ShowBlogController::feed() — resolves BlogFeed, loads articles via the existing Article::published() scope (newest first; drafts and scheduled posts excluded), eager-loads the author, and returns the document with an application/rss+xml content type.
  • routes/web.php — registers blog/feed before blog/{article} so it isn't captured as an article slug.
  • resources/views/components/layout.blade.php — adds a <link rel="alternate" type="application/rss+xml"> tag so browsers and readers can auto-discover the feed.

Per-item content

Each <item> carries the post title, permalink (link + guid), pubDate, author (dc:creator), the post excerpt as the description (not a trimmed article body), and the OpenGraph image via media:content when one is set.

Notes

  • lastBuildDate reflects the most recent article updated_at (i.e. the last time feed content actually changed — new post or edit), per the RSS spec, rather than request/generation time. This keeps the value stable across requests so readers' conditional-fetch/caching still works.
  • package-lock.json had an unrelated workspace rename in the working tree; it was intentionally left out of this PR.

Tests

tests/Feature/BlogFeedTest.php covers: content type, published posts appearing, drafts/scheduled excluded, reverse-chronological order, the OpenGraph image tag (present and absent), lastBuildDate tracking the latest update, and feed autodiscovery on the blog page. All green, and the existing BlogTest suite still passes.

🤖 Generated with Claude Code

Expose the blog at /blog/feed (route blog.feed) as an RSS 2.0 document,
generated with DOMDocument for correctly-escaped, cleanly-indented XML.
Items reuse the Article published() scope (newest first, drafts and
scheduled posts excluded) and carry the excerpt as the description plus
the OpenGraph image via media:content. lastBuildDate tracks the most
recent article update, and the layout advertises the feed for reader
autodiscovery.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@simonhamp simonhamp marked this pull request as ready for review July 3, 2026 11:17
@simonhamp simonhamp merged commit 394ef38 into main Jul 3, 2026
2 checks passed
@simonhamp simonhamp deleted the blog-rss-feed branch July 3, 2026 11:18
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