XML
Parcel 支持使用 @parcel/transformer-xml
插件转换 XML 文件中定义的 RSS 和 Atom 提要。当检测到 .xml
、.rss
或 .atom
文件时,它将自动安装到你的项目中。
¥Parcel supports transforming RSS and Atom feeds defined in XML files using the @parcel/transformer-xml
plugin. When a .xml
, .rss
, or .atom
file is detected, it will be installed into your project automatically.
依赖
#¥Dependencies
Parcel 会转换 RSS 和 Atom 提要中的 URL 引用,以匹配最终名称和 公共网址,包括适当的 内容哈希。
¥Parcel transforms URL references within RSS and Atom feeds to match the final name and public URL, including content hashes where appropriate.
在 RSS 中,这包括:
¥In RSS this includes:
-
<link>
-
<url>
-
<comments>
-
<enclosure>
在 Atom 中,这包括:
¥In Atom this includes:
-
<link>
-
<icon>
-
<logo>
嵌入 HTML
#¥Embedded HTML
RSS 和 Atom 提要中嵌入的 HTML 和 XHTML 内容也会按照 HTML 中的描述进行转换。嵌入 HTML 中的所有 URL 引用也将被转换,引用的文件将使用相关的 Parcel 管道进行处理。
¥Embedded HTML and XHTML content inside RSS and Atom feeds is also transformed as described in HTML. All URL references within embedded HTML will also be transformed, and the referenced files will be processed with the relevant Parcel pipelines.
HTML 参考
#¥HTML references
可以使用 <link>
元素从 HTML 文件引用 RSS 和 Atom 提要。根据需要使用 application/rss+xml
或 application/atom+xml
mime 类型。Parcel 将确保以这种方式引用的 XML 文件不会收到内容哈希值,并且随着时间的推移具有一致的 URL。
¥RSS and Atom feeds can be referenced from an HTML file using the <link>
element. Use the application/rss+xml
or application/atom+xml
mime type as appropriate. Parcel will ensure that XML files referenced this way do not receive a content hash and have a consistent URL over time.
<link
href="feed.xml"
rel="alternate"
type="application/rss+xml"
title="Blog RSS feed" />
示例
#¥Example
此示例显示包含单个入口的 Atom feed。两个 <link>
元素中的 URL 引用将被重写以包含公共 URL,并且帖子内容中引用的图片将被处理并对内容进行哈希处理。
¥This example shows an Atom feed containing a single entry. The URL references in the two <link>
elements will be rewritten to include the public URL, and the image referenced in the content of the post will be processed and content hashed.
<?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>