Composables
useXafRssFeed
RSS 2.0 feed generation composable — builds channel metadata from xAffiliate.brand defaults and generates feed XML for server routes.
useXafRssFeed
RSS 2.0 feed generation for the review-site family. Auto-imported. Wraps pure XML utilities with automatic channel-metadata defaults pulled from xAffiliate.brand (site name, URL, tagline), so a server route can emit a valid feed with minimal code. Pair with <XAFRssFeedLink> to advertise the feed in the page head.
Usage
// server/routes/feed.xml.ts
export default defineEventHandler((event) => {
const { buildChannel, generateFeed, formatRssDate } = useXafRssFeed()
const channel = buildChannel({
title: 'Best Kitchen Gear Reviews', // overrides xAffiliate.brand.name
description: 'Latest reviews and recommendations.',
})
const xml = generateFeed(channel, [
{
title: 'Best Coffee Makers',
link: 'https://bestkitchengear.com/reviews/best-coffee-makers',
pubDate: formatRssDate(new Date()),
description: 'We tested 12 coffee makers…',
},
])
setResponseHeader(event, 'content-type', 'application/rss+xml')
return xml
})
Returns
| Key | Type | Description |
|---|---|---|
buildChannel | (overrides?: Partial<RssFeedChannel>) => RssFeedChannel | Build a channel object, merging xAffiliate.brand defaults (name → title, url → link, tagline → description) with overrides. |
generateFeed | (channel: RssFeedChannel, items: RssFeedItem[]) => string | Generate the full RSS 2.0 XML string. |
escapeXml | (str: string) => string | Escape XML special characters. |
formatRssDate | (date: string | Date | number) => string | Format a date as an RFC 822 string (RSS 2.0 compliant). |
AI Context
composable: useXafRssFeed
package: "@xenterprises/nuxt-x-affiliate"
use-when: >
Generating an RSS 2.0 feed from a server route. Channel metadata
defaults come from xAffiliate.brand; pair with <XAFRssFeedLink> for
head auto-discovery.
