X Enterprises
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

KeyTypeDescription
buildChannel(overrides?: Partial<RssFeedChannel>) => RssFeedChannelBuild a channel object, merging xAffiliate.brand defaults (nametitle, urllink, taglinedescription) with overrides.
generateFeed(channel: RssFeedChannel, items: RssFeedItem[]) => stringGenerate the full RSS 2.0 XML string.
escapeXml(str: string) => stringEscape XML special characters.
formatRssDate(date: string | Date | number) => stringFormat 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.
Copyright © 2026