Skip to content

Commit 46c1bf9

Browse files
committed
new: expand xmlns guide to explain usage
1 parent 147938d commit 46c1bf9

1 file changed

Lines changed: 16 additions & 11 deletions

File tree

packages/astro-rss/README.md

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ An absolute path to an XSL stylesheet in your project. If you don’t have an RS
158158

159159
Type: `string (optional)`
160160

161-
A string of valid XML to be injected between your feed's `<description>` and `<item>` tags.
161+
A string of valid XML to be injected between your feed's `<description>` and `<item>` tags.
162162

163163
This can be used to pass additional data outside of the standard RSS spec, and is commonly used to set a language for your feed:
164164

@@ -175,23 +175,28 @@ export const GET = () => rss({
175175

176176
Type: `Record<string, string> (optional)`
177177

178-
An object mapping a set of `xmlns` suffixes to strings of metadata on the opening `<rss>` tag.
178+
An object mapping a set of `xmlns` suffixes to strings values on the opening `<rss>` tag.
179179

180-
For example, this object:
180+
Suffixes expand the available XML tags in your RSS feed, so your content may be read by third-party sources like podcast services or blogging platforms. You'll likely combine `xmlns` with the [`customData`](#customData) attribute to insert custom tags for a given platform.
181+
182+
This example applies the `itunes` suffix to an RSS feed of podcasts, and uses `customData` to define tags for the author and episode details:
181183

182184
```js
183185
rss({
184-
...
185-
xmlns: { h: 'http://www.w3.org/TR/html4/' },
186+
// ...
187+
xmlns: {
188+
itunes: 'http://www.itunes.com/dtds/podcast-1.0.dtd',
189+
},
190+
customData: '<itunes:author>MF Doom</itunes:author>',
191+
items: episodes.map((episode) => ({
192+
// ...
193+
customData: `<itunes:episodeType>${episode.frontmatter.type}</itunes:episodeType>` +
194+
`<itunes:duration>${episode.frontmatter.duration}</itunes:duration>` +
195+
`<itunes:explicit>${episode.frontmatter.explicit || false}</itunes:explicit>`,
196+
})),
186197
})
187198
```
188199

189-
Will inject the following XML:
190-
191-
```xml
192-
<rss xmlns:h="http://www.w3.org/TR/html4/"...
193-
```
194-
195200
### `trailingSlash`
196201

197202
Type: `boolean (optional)`

0 commit comments

Comments
 (0)