XML
Parcel 支援使用 @parcel/transformer-xml
外掛轉換 XML 檔案中定義的 RSS 和 Atom 饋送。當偵測到 .xml
、.rss
或 .atom
檔案時,它會自動安裝到您的專案中。
相依性
#Parcel 會轉換 RSS 和 Atom 饋送中的 URL 參照,以符合最終名稱和 公開 URL,包括適用的 內容雜湊。
在 RSS 中,這包括
<link>
<url>
<comments>
<enclosure>
在 Atom 中,這包括
<link>
<icon>
<logo>
嵌入式 HTML
#RSS 和 Atom 饋送中的嵌入式 HTML 和 XHTML 內容也會根據 HTML 中的說明進行轉換。嵌入式 HTML 中的所有 URL 參照也會進行轉換,並且會使用相關的 Parcel 管線處理所參照的檔案。
HTML 參照
#可以使用 <link>
元素從 HTML 檔案參照 RSS 和 Atom 饋送。適當地使用 application/rss+xml
或 application/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>