Vue Nuxt
Tips & Tricks

A collection of Vue, Nuxt and Vite tips, tricks and good practices.

In Nuxt Content, it is really easy to create an RSS feed of all your content.

// api/routes/rss.ts
import RSS from 'rss';
import { serverQueryContent } from '#content/server';

export default defineEventHandler(async (event) => {
    const BASE_URL = '';

    const feed = new RSS({
        title: 'Your title',
        site_url: BASE_URL,
        feed_url: `${BASE_URL}/rss.xml`

    const docs = await serverQueryContent(event)
        .sort({ date: -1 })
        .where({ _partial: false })

    for (const doc of docs) {
            title: doc.title ?? '-',
            url: `${BASE_URL}${doc._path}`,
            description: doc.description

    const feedString = feed.xml({ indent: true });

    setHeader(event, 'content-type', 'text/xml');

    return feedString;