Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The RSS spec does not require an item title, but astrojs/rss does #9577

Closed
1 task
robmen opened this issue Jan 2, 2024 · 6 comments · Fixed by #9610
Closed
1 task

The RSS spec does not require an item title, but astrojs/rss does #9577

robmen opened this issue Jan 2, 2024 · 6 comments · Fixed by #9610
Assignees
Labels
- P3: minor bug An edge case that only affects very specific usage (priority) pkg: rss Related to the `@astrojs/rss` package (scope)

Comments

@robmen
Copy link
Contributor

robmen commented Jan 2, 2024

Astro Info

Astro                    v4.0.8
Node                     v20.10.0
System                   Windows (x64)
Package Manager          pnpm
Output                   static
Adapter                  none
Integrations             @astrojs/sitemap

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

The RSS specification calls out that the item title is optional if the item description is present:

All elements of an item are optional, however at least one of title or description must be present.
-- https://cyber.harvard.edu/rss/rss.html#hrelementsOfLtitemgt

However the rss() in astro requires an title:

08:49:48 λ src/pages/blog/rss.xml.js
08:49:48   └─ /blog/rss.xml[RSS] Invalid or missing options:
Invalid input (items)
The `items` property requires properly typed `title`, `pubDate`, and `link` keys.
Check your collection's schema, and visit https://docs.astro.build/en/guides/rss/#generating-items for more info.

What's the expected result?

Do not require a title element for RSS items if a description element is present.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-aoal5a?file=src%2Fcontent%2Fblog%2Fpost-only-desc.md

Participation

  • I am willing to submit a pull request for this issue.
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Jan 2, 2024
@florian-lefebvre florian-lefebvre added the pkg: rss Related to the `@astrojs/rss` package (scope) label Jan 2, 2024
@bluwy
Copy link
Member

bluwy commented Jan 4, 2024

All elements of an item are optional, however at least one of title or description must be present.
-- cyber.harvard.edu/rss/rss.html#hrelementsOfLtitemgt

If I understand this correctly, it means that if an item has no elements (because it's optional), then at least a title or description needs to exist. It doesn't mean that on a proper formed item with title, link, and description, you can choose either a title or description to exist.

Plus I think it's fair for Astro to enforce some defaults here to generate a better RSS feed. pubDate is also optional per the spec, but Astro enforces it. So I'm leaning towards this not being an issue.

@robmen
Copy link
Contributor Author

robmen commented Jan 4, 2024

If I understand this correctly, it means that if an item has no elements (because it's optional), then at least a title or description needs to exist.

Correct.

It doesn't mean that on a proper formed item with title, link, and description, you can choose either a title or description to exist.

This is not correct. The designer of the RSS specifications, Dave Winer - @scripting, regularly calls out that RSS items should not require titles. It is an important distinction he makes.

Title-less RSS items allow one to build a (for lack of a better word) "micro-blogging" site like Twitter or Bluesky. In fact, Bluesky already produces RSS feeds for users and they do not have titles.

I hit this issue when attempting to build a textcasting system using Astro. Textcasting is a (IMHO) honorable effort by @scripting to reboot blogging and personal publication. Title-less posts are specifically called out twice:

Titles are optional. Any post can have a title, or not. If you're writing something like a quick social media post, there's no need for a title. But if you're writing something longer, you might need one. It must be up to the writer to decide if a post gets a title. https://textcasting.org/#1683634956000
...
For example, there was a time when the leading feed reader app required posts to have titles, and the leading microblogging site said they couldn't have them. That meant not only didn't they share data, they couldn't. https://textcasting.org/#1670873252000

Please do not close this as a non-issue. I really hope that rss() would be capable of following the RSS spec.

@scripting
Copy link

You don't have to go by what I say, it's very clear in the RSS 2.0 spec.

All elements of an item are optional, however at least one of title or description must be present.

It was put there so that writers could choose whether an item required a title or not. The idea was to empower the writer, as it is with textcasting, as you note.

@florian-lefebvre
Copy link
Member

@florian-lefebvre florian-lefebvre added - P3: minor bug An edge case that only affects very specific usage (priority) and removed needs triage Issue needs to be triaged labels Jan 4, 2024
@robmen
Copy link
Contributor Author

robmen commented Jan 4, 2024

I guessed that was the problem. Unfortunately, my Zod-fu is not strong enough to know how to represent "at least one of" across multiple fields.

I am interested in the solution because I have a similar case in my own config.ts.

In my config.ts, I made all the fields .optional() and gave up on the validation. 😢 I suppose that could be an option here, but I expect you all know much more about Zod than I do and might know a way to maintain the validation.

@bluwy
Copy link
Member

bluwy commented Jan 5, 2024

I took another look at the spec, and I think I was confused between a "channel" and an "item" where both have overlapping sub-elements that are required/optional. So I suppose we can loosen up the schema for "item" in Astro today. But on top of allowing either title and description, we should also make pubDate and link optional, and adjust the error message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P3: minor bug An edge case that only affects very specific usage (priority) pkg: rss Related to the `@astrojs/rss` package (scope)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants