Skip to content

Custom feeds#165

Merged
eelcoj merged 2 commits intomainfrom
custom-feeds
Mar 18, 2026
Merged

Custom feeds#165
eelcoj merged 2 commits intomainfrom
custom-feeds

Conversation

@eelcoj
Copy link
Copy Markdown
Contributor

@eelcoj eelcoj commented Mar 17, 2026

Allows overriding feed output by creating templates in app/views/content/{collection_name}/{rss,atom,json}.erb.

Templates have access to: collection, resources, config

Example app/views/content/posts/json.erb:

{
  "version": "https://jsonfeed.org/version/1",
  "title": "<%= config.title || collection.name %>",
  "items": <%= resources.map { |resource| {
    id: resource.id,
    title: resource.metadata.title,
    url: "/posts/#{resource.slug}",
    content_html: resource.content
  }}.to_json %>
}

Also refactored the default feeds to be created through erb template instead of using Nokogiri. Biggest reason for that was fixing the atom:link, described here #146

Closes #61

eelcoj added 2 commits March 17, 2026 12:35
Allows overriding feed output by creating templates in `app/views/content/{collection_name}/{rss,atom,json}.erb`.

Templates have access to: `collection`, `resources`, `config`

Example `app/views/content/posts/json.erb`:
```erb
{
  "version": "https://jsonfeed.org/version/1",
  "title": "<%= config.title || collection.name %>",
  "items": <%= resources.map { |resource| {
    id: resource.id,
    title: resource.metadata.title,
    url: "/posts/#{resource.slug}",
    content_html: resource.content
  }}.to_json %>
}
```
@eelcoj eelcoj merged commit 8074f16 into main Mar 18, 2026
4 of 9 checks passed
@eelcoj eelcoj deleted the custom-feeds branch March 18, 2026 04:21
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.

Make feed's body configurable

1 participant