XML

Parcel 支持使用 @parcel/transformer-xml 插件转换 XML 文件中定义的 RSSAtom 提要。当检测到 .xml.rss.atom 文件时,它将自动安装到您的项目中。

依赖项

#

Parcel 将 RSS 和 Atom 提要中的 URL 引用转换为与最终名称和 公共 URL 相匹配,包括在适当情况下使用 内容哈希

在 RSS 中,这包括

在 Atom 中,这包括

嵌入式 HTML

#

RSS 和 Atom 提要中的嵌入式 HTML 和 XHTML 内容也会按照 HTML 中的描述进行转换。嵌入式 HTML 中的所有 URL 引用也将被转换,并且引用的文件将使用相关的 Parcel 管道进行处理。

HTML 引用

#

可以使用 <link> 元素从 HTML 文件引用 RSS 和 Atom 提要。使用 application/rss+xmlapplication/atom+xml MIME 类型,具体取决于情况。Parcel 将确保以这种方式引用的 XML 文件不会收到内容哈希,并且随着时间的推移具有始终一致的 URL。

<link
href="feed.xml"
rel="alternate"
type="application/rss+xml"
title="Blog RSS feed" />

示例

#

此示例显示了一个包含单个条目的 Atom 提要。两个 <link> 元素中的 URL 引用将被重写以包含公共 URL,并且帖子内容中引用的图像将被处理并进行内容哈希。

<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>Example Feed</title>
<subtitle>A subtitle.</subtitle>
<link href="/" />
<id>urn:uuid:60a76c80-d399-11d9-b91C-0003939e0af6</id>
<updated>2021-12-13T18:30:02Z</updated>
<entry>
<title>Awesome post</title>
<link href="post.html" />
<id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id>
<updated>2021-12-13T18:30:02Z</updated>
<summary>Some text.</summary>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<p>This is the entry content.</p>
<img src="image.png" />
</div>
</content>
<author>
<name>John Doe</name>
<email>johndoe@example.com</email>
</author>
</entry>
</feed>