fix(core): make the atom format spec-compliant (#20723)

* fix: remove the src attribute of atom:content

The src attribute is to replace the inner content, not to mark its source.

RFC4287:

> 4.1.3.2.  The "src" Attribute
>
>  atom:content MAY have a "src" attribute, whose value MUST be an IRI
>  reference [RFC3987].  If the "src" attribute is present, atom:content
>  MUST be empty.  Atom Processors MAY use the IRI to retrieve the
>  content and MAY choose to ignore remote content or to present it in a
>  different manner than local content.
>
>  If the "src" attribute is present, the "type" attribute SHOULD be
>  provided and MUST be a MIME media type [MIMEREG], rather than "text",
>  "html", or "xhtml".  The value is advisory; that is to say, when the
>  corresponding URI (mapped from an IRI, if necessary) is dereferenced,
>  if the server providing that content also provides a media type, the
>  server-provided media type is authoritative.

* fix: move <language> to xml:lang

* fix: remove <webMaster> in atom

* fix: use ISO format to display date in atom & always have <updated>

* fix: use ISO date for feed <updated> in atom

* fix: add <link rel=self> for atom
This commit is contained in:
Yufan You
2026-07-08 21:37:45 +08:00
committed by GitHub
parent ee32cffa05
commit 12a75059dd
+7 -10
View File
@@ -3,15 +3,14 @@ import type { FC } from 'hono/jsx';
import type { Data } from '@/types';
const RSS: FC<{ data: Data }> = ({ data }) => (
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:rsshub="http://rsshub.app/xml/schemas">
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:rsshub="http://rsshub.app/xml/schemas" xml:lang={data.language || 'en'}>
<title>{data.title || 'RSSHub'}</title>
<link href={data.link || 'https://docs.rsshub.app'} />
<link rel="alternate" href={data.link || 'https://docs.rsshub.app'} />
<link rel="self" href={data.atomlink} type="application/atom+xml" />
<id>{data.id || data.link}</id>
<subtitle>{data.description || data.title} - Powered by RSSHub</subtitle>
<generator>RSSHub</generator>
<webMaster>contact@rsshub.app (RSSHub)</webMaster>
<language>{data.language || 'en'}</language>
<updated>{data.lastBuildDate}</updated>
<updated>{new Date(data.lastBuildDate || new Date()).toISOString()}</updated>
<author>
<name>{data.author || 'RSSHub'}</name>
</author>
@@ -21,13 +20,11 @@ const RSS: FC<{ data: Data }> = ({ data }) => (
{data.item?.map((item) => (
<entry>
<title>{item.title}</title>
<content type="html" src={item.link}>
{item.description}
</content>
<content type="html">{item.description}</content>
<link href={item.link} />
<id>{item.guid || item.link || item.title}</id>
{item.pubDate && <published>{item.pubDate}</published>}
{item.updated && <updated>{item.updated || item.pubDate}</updated>}
{item.pubDate && <published>{new Date(item.pubDate).toISOString()}</published>}
<updated>{new Date(item.updated || item.pubDate || new Date()).toISOString()}</updated>
{item.author && (
<author>
<name>{item.author}</name>