Add RSS feed for the blog#412
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds an RSS 2.0 feed for the blog at
/blog/feed(route nameblog.feed).app/Support/BlogFeed.php— builds the feed withDOMDocument, so the XML is correctly escaped and cleanly indented (declarations for theatom,dc, andmedianamespaces sit once on the root). XML is data, not markup, so it's generated rather than rendered through a Blade view.ShowBlogController::feed()— resolvesBlogFeed, loads articles via the existingArticle::published()scope (newest first; drafts and scheduled posts excluded), eager-loads the author, and returns the document with anapplication/rss+xmlcontent type.routes/web.php— registersblog/feedbeforeblog/{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 thedescription(not a trimmed article body), and the OpenGraph image viamedia:contentwhen one is set.Notes
lastBuildDatereflects the most recent articleupdated_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.jsonhad an unrelated workspace rename in the working tree; it was intentionally left out of this PR.Tests
tests/Feature/BlogFeedTest.phpcovers: content type, published posts appearing, drafts/scheduled excluded, reverse-chronological order, the OpenGraph image tag (present and absent),lastBuildDatetracking the latest update, and feed autodiscovery on the blog page. All green, and the existingBlogTestsuite still passes.🤖 Generated with Claude Code