import { BlogCollectionItem } from '@nuxt/content' const clean = (value: string) => value .replace(/&/g, '&') .replace(//g, '>') .replace(/ä/g, 'ä') .replace(/ö/g, 'ö') .replace(/ü/g, 'ü') .replace(/ß/g, 'ß') const makeItem = (article: BlogCollectionItem, base: string) => ` ${clean(article.title)} ${clean(article.description)} ${base}${article.path} ` const simpleDate = (date: Date) => { date.setDate(date.getDate() + 1) return `${date.getFullYear()}-${`${date.getMonth() + 1}`.padStart(2, '0')}-${`${date.getDate()}`.padStart(2, '0')}` } export default defineEventHandler(async event => { const baseUrl = getRequestURL(event) const blogUrl = `${baseUrl.protocol}//${baseUrl.host}` const articles = await queryCollection(event, 'blog') .where('date', '<', simpleDate(new Date())) .order('date', 'DESC') .all() const xmlItems = articles.map(article => makeItem(article, blogUrl)).join('') return ` Blogfussel ${baseUrl}/blog für mehr Fussel im Blog de ${xmlItems} ` })