Files
RSSHub/lib/views/atom.tsx
T
Yufan You 12a75059dd 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
2026-07-08 21:37:45 +08:00

48 lines
2.2 KiB
TypeScript

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" xml:lang={data.language || 'en'}>
<title>{data.title || 'RSSHub'}</title>
<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>
<updated>{new Date(data.lastBuildDate || new Date()).toISOString()}</updated>
<author>
<name>{data.author || 'RSSHub'}</name>
</author>
{data.icon && <icon>{data.icon}</icon>}
{data.logo && <logo>{data.logo}</logo>}
{data.item?.map((item) => (
<entry>
<title>{item.title}</title>
<content type="html">{item.description}</content>
<link href={item.link} />
<id>{item.guid || item.link || item.title}</id>
{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>
</author>
)}
{typeof item.category === 'string' ? <category term={item.category}></category> : item.category?.map((c) => <category term={c}></category>)}
{item.media &&
Object.entries(item.media).map(([key, value]) => {
const Tag = `media:${key}`;
return <Tag {...value} />;
})}
{item.upvotes ? <rsshub:upvotes>{item.upvotes}</rsshub:upvotes> : ''}
{item.downvotes ? <rsshub:downvotes>{item.downvotes}</rsshub:downvotes> : ''}
{item.comments ? <rsshub:comments>{item.comments}</rsshub:comments> : ''}
</entry>
))}
</feed>
);
export default RSS;