Skip to content

Option to split feeds - #209

Open
eelcoj wants to merge 1 commit into
mainfrom
split-feeds
Open

Option to split feeds#209
eelcoj wants to merge 1 commit into
mainfrom
split-feeds

Conversation

@eelcoj

@eelcoj eelcoj commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Common use case could be offering a category-separate posts feeds.

Usage:

class Content::Post < Perron::Resource
  configure do |config|
    config.feeds.atom.enabled = true
    config.feeds.atom.split_by :category  # auto-derived path
    config.feeds.atom.split_by :category, path: "feeds/by-cat/:value.atom"  # explicit path
  end
end

For Rails Designer's site this would create:

<link rel="alternate" type="application/atom+xml" title="Posts Atom Feed" href="http://localhost:3000/feed.xml" />

<link rel="alternate" type="application/atom+xml" title="Posts: Viewcomponent Atom Feed" href="http://localhost:3000/feed/category/viewcomponent.xml" />
<link rel="alternate" type="application/atom+xml" title="Posts: Hotwire Atom Feed" href="http://localhost:3000/feed/category/hotwire.xml" />
<link rel="alternate" type="application/atom+xml" title="Posts: Tailwindcss Atom Feed" href="http://localhost:3000/feed/category/tailwindcss.xml" />
<link rel="alternate" type="application/atom+xml" title="Posts: Updates Atom Feed" href="http://localhost:3000/feed/category/updates.xml" />
<link rel="alternate" type="application/atom+xml" title="Posts: Rails Atom Feed" href="http://localhost:3000/feed/category/rails.xml" />
<link rel="alternate" type="application/atom+xml" title="Posts: Javascript Atom Feed" href="http://localhost:3000/feed/category/javascript.xml" />
<link rel="alternate" type="application/atom+xml" title="Posts: Css Atom Feed" href="http://localhost:3000/feed/category/css.xml" />
<link rel="alternate" type="application/atom+xml" title="Posts: Design Atom Feed" href="http://localhost:3000/feed/category/design.xml" />
<link rel="alternate" type="application/atom+xml" title="Posts: Html Atom Feed" href="http://localhost:3000/feed/category/html.xml" />
  • Besides path/href, also support option for customisable title

Common use case could be offering a category-separate posts feeds.

Usage:
```ruby
class Content::Post < Perron::Resource
  configure do |config|
    config.feeds.atom.enabled = true
    config.feeds.atom.split_by :category  # auto-derived path
    config.feeds.atom.split_by :category, path: "feeds/by-cat/:value.atom"  # explicit path
  end
end
```
Comment thread lib/perron/feeds.rb
split_values(collection.resources, feed[:split_by][:extractor]).each do |value|
split_path = split_path_for(feed, value)
split_url = URI.join(url.root_url, split_path).to_s
split_title = "#{collection.name.humanize}: #{value.to_s.humanize} #{type.to_s.humanize} Feed"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be a configurable option, similar to path.

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