mirror of
https://github.com/withastro/astro.git
synced 2024-12-16 21:46:22 -05:00
Fix RSS dategen (#156)
This commit is contained in:
parent
f39a91e6ec
commit
1d498facc8
3 changed files with 7 additions and 6 deletions
|
@ -47,8 +47,8 @@ const data = Astro.fetchContent('../pages/post/*.md'); // returns an array of po
|
||||||
|
|
||||||
`Astro.request` returns an object with the following properties:
|
`Astro.request` returns an object with the following properties:
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| :----- | :------- | :--------------------------------------------------------------------------------------------------------- |
|
| :---- | :---- | :------------------------------------- |
|
||||||
| `url` | `URL` | The URL of the request being rendered. |
|
| `url` | `URL` | The URL of the request being rendered. |
|
||||||
|
|
||||||
### `collection`
|
### `collection`
|
||||||
|
@ -128,7 +128,7 @@ export async function createCollection() {
|
||||||
item: (item) => ({
|
item: (item) => ({
|
||||||
title: item.title,
|
title: item.title,
|
||||||
description: item.description,
|
description: item.description,
|
||||||
pubDate: item.pubDate,
|
pubDate: item.pubDate + 'Z', // enforce GMT timezone (otherwise it’ll be different based on where it’s built)
|
||||||
/** (optional) add arbitrary XML to each <item> */
|
/** (optional) add arbitrary XML to each <item> */
|
||||||
customData: `<itunes:episodeType>${item.type}</itunes:episodeType>
|
customData: `<itunes:episodeType>${item.type}</itunes:episodeType>
|
||||||
<itunes:duration>${item.duration}</itunes:duration>
|
<itunes:duration>${item.duration}</itunes:duration>
|
||||||
|
|
|
@ -8,8 +8,9 @@ import { fileURLToPath } from 'url';
|
||||||
|
|
||||||
const RSS = suite('RSS Generation');
|
const RSS = suite('RSS Generation');
|
||||||
|
|
||||||
const snapshot = `<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title><![CDATA[MF Doomcast]]></title><description><![CDATA[The podcast about the things you find on a picnic, or at a picnic table]]></description><link>https://mysite.dev/feed/episodes.xml</link><language>en-us</language><itunes:author>MF Doom</itunes:author><item><title><![CDATA[Rap Snitch Knishes (feat. Mr. Fantastik)]]></title><link>https://mysite.dev/episode/rap-snitch-knishes/</link><description><![CDATA[Complex named this song the “22nd funniest rap song of all time.”]]></description><pubDate>Tue, 16 Nov 2004 00:00:00 GMT</pubDate><itunes:episodeType>music</itunes:episodeType><itunes:duration>172</itunes:duration><itunes:explicit>true</itunes:explicit></item><item><title><![CDATA[Fazers]]></title><link>https://mysite.dev/episode/fazers/</link><description><![CDATA[Rhapsody ranked Take Me to Your Leader 17th on its list “Hip-Hop’s Best Albums of the Decade”]]></description><pubDate>Wed, 02 Jul 2003 23:00:00 GMT</pubDate><itunes:episodeType>music</itunes:episodeType><itunes:duration>197</itunes:duration><itunes:explicit>true</itunes:explicit></item><item><title><![CDATA[Rhymes Like Dimes (feat. Cucumber Slice)]]></title><link>https://mysite.dev/episode/rhymes-like-dimes/</link><description><![CDATA[Operation: Doomsday has been heralded as an underground classic that established MF Doom's rank within the underground hip-hop scene during the early to mid-2000s.\n` +
|
const snapshot =
|
||||||
']]></description><pubDate>Mon, 18 Oct 1999 23:00:00 GMT</pubDate><itunes:episodeType>music</itunes:episodeType><itunes:duration>259</itunes:duration><itunes:explicit>true</itunes:explicit></item></channel></rss>'
|
`<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title><![CDATA[MF Doomcast]]></title><description><![CDATA[The podcast about the things you find on a picnic, or at a picnic table]]></description><link>https://mysite.dev/feed/episodes.xml</link><language>en-us</language><itunes:author>MF Doom</itunes:author><item><title><![CDATA[Rap Snitch Knishes (feat. Mr. Fantastik)]]></title><link>https://mysite.dev/episode/rap-snitch-knishes/</link><description><![CDATA[Complex named this song the “22nd funniest rap song of all time.”]]></description><pubDate>Tue, 16 Nov 2004 00:00:00 GMT</pubDate><itunes:episodeType>music</itunes:episodeType><itunes:duration>172</itunes:duration><itunes:explicit>true</itunes:explicit></item><item><title><![CDATA[Fazers]]></title><link>https://mysite.dev/episode/fazers/</link><description><![CDATA[Rhapsody ranked Take Me to Your Leader 17th on its list “Hip-Hop’s Best Albums of the Decade”]]></description><pubDate>Thu, 03 Jul 2003 00:00:00 GMT</pubDate><itunes:episodeType>music</itunes:episodeType><itunes:duration>197</itunes:duration><itunes:explicit>true</itunes:explicit></item><item><title><![CDATA[Rhymes Like Dimes (feat. Cucumber Slice)]]></title><link>https://mysite.dev/episode/rhymes-like-dimes/</link><description><![CDATA[Operation: Doomsday has been heralded as an underground classic that established MF Doom's rank within the underground hip-hop scene during the early to mid-2000s.\n` +
|
||||||
|
']]></description><pubDate>Tue, 19 Oct 1999 00:00:00 GMT</pubDate><itunes:episodeType>music</itunes:episodeType><itunes:duration>259</itunes:duration><itunes:explicit>true</itunes:explicit></item></channel></rss>';
|
||||||
|
|
||||||
const cwd = new URL('./fixtures/astro-rss', import.meta.url);
|
const cwd = new URL('./fixtures/astro-rss', import.meta.url);
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ export async function createCollection() {
|
||||||
title: item.title,
|
title: item.title,
|
||||||
link: item.url,
|
link: item.url,
|
||||||
description: item.description,
|
description: item.description,
|
||||||
pubDate: item.pubDate,
|
pubDate: item.pubDate + 'Z',
|
||||||
customData: `<itunes:episodeType>${item.type}</itunes:episodeType>` +
|
customData: `<itunes:episodeType>${item.type}</itunes:episodeType>` +
|
||||||
`<itunes:duration>${item.duration}</itunes:duration>` +
|
`<itunes:duration>${item.duration}</itunes:duration>` +
|
||||||
`<itunes:explicit>${item.explicit || false}</itunes:explicit>`,
|
`<itunes:explicit>${item.explicit || false}</itunes:explicit>`,
|
||||||
|
|
Loading…
Reference in a new issue