Skip to content

Add featured image, tags, and categories to RSS feed generation - #122

Draft
bencounsell wants to merge 1 commit into
mainfrom
cursor/rss-extra-fields-ff2d
Draft

Add featured image, tags, and categories to RSS feed generation#122
bencounsell wants to merge 1 commit into
mainfrom
cursor/rss-extra-fields-ff2d

Conversation

@bencounsell

Copy link
Copy Markdown
Member

Summary

Implements RSS feed generation that includes featured images, tags, and categories from markdown frontmatter — addressing the customer request in the forum thread.

Related to #71

What changed

New: RSS feed builder (shared/rss/rss-item-builder.js)

A JavaScript RSS 2.0 feed builder that generates standards-compliant XML with support for:

  • Featured images via three complementary RSS elements:
    • <enclosure> — standard RSS 2.0 image attachment
    • <media:content> — Media RSS (Yahoo mrss) for richer feed readers
    • <media:thumbnail> — Media RSS thumbnail hint
  • Tags via <category> elements (one per tag)
  • Categories via <category> elements (one per category)
  • Atom self-link for feed auto-discovery

The builder accepts the image frontmatter key in both forms used by the CMS:

  • String URL: image: "https://example.com/hero.jpg"
  • Object with src: image: { src: "https://example.com/hero.jpg" }

New: PHP feed template (shared/templates/rss/feed.php)

A server-side PHP template that reads markdown files with YAML frontmatter from a CMS content directory and produces RSS 2.0 XML. Follows the same pattern as the gallery's remote-folder PHP templates.

New: Tests (test/rss-feed.test.mjs)

23 tests covering:

  • XML escaping for all five special characters
  • RFC 822 date conversion
  • Image URL resolution (string and object forms)
  • MIME type detection for all common image formats
  • <enclosure>, <media:content>, <media:thumbnail> emission for featured images
  • <category> emission for string tags, enriched tag objects, and categories
  • Combined tags + categories output
  • Full feed structure with Media RSS and Atom namespaces
  • End-to-end round-trip with generated XML fixture

Frontmatter keys

All optional. These reuse existing CMS markdown collection conventions — no new keys were invented for fields the CMS already supports.

Key Type Description
title string Post title
date_published string Publication date (ISO 8601 or any parseable format)
description string Plain-text excerpt or summary
image string or { src } Featured/header image URL
tags string[] or { title, url }[] Tag labels (emitted as <category>)
categories string[] Category labels (emitted as <category>)
link string Item permalink
guid string Globally unique identifier (defaults to link)

Test results

# tests 115
# pass 115
# fail 0

All 23 new RSS tests pass alongside the 92 existing component tests.

Open in Web Open in Cursor 

…port

RSS item output now includes:

1. Featured/header image via <enclosure>, <media:content>, and
   <media:thumbnail> — uses the existing 'image' frontmatter key
   (string URL or object with 'src' property, matching CMS conventions)

2. Tags from frontmatter via <category> elements — uses the existing
   'tags' frontmatter key (array of strings or enriched tag objects)

3. Categories from frontmatter via <category> elements — uses a new
   'categories' frontmatter key (array of strings)

New files:
- shared/rss/rss-item-builder.js: JavaScript RSS 2.0 feed builder with
  support for Media RSS namespace (xmlns:media) and Atom self-link
- shared/templates/rss/feed.php: Server-side PHP template that reads
  markdown frontmatter from a CMS content directory and generates
  standards-compliant RSS 2.0 XML
- test/rss-feed.test.mjs: 23 tests covering all RSS generation paths
  including image enclosure, media:content, media:thumbnail, category
  emission for tags and categories, XML escaping, and full feed
  round-trip with generated fixture

Frontmatter keys (all optional, matching existing CMS conventions):
  title          — post title (string)
  date_published — publication date (ISO 8601)
  description    — plain-text excerpt/summary
  image          — featured image URL (string) or { src: URL }
  tags           — array of tag labels or enriched { title, url } objects
  categories     — array of category labels
  link           — item permalink
  guid           — globally unique identifier (defaults to link)

Related to #71

Co-authored-by: Ben Counsell <bencounsell@users.noreply.github.com>
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.

2 participants