Saltar al contenido principal

Function: useAstroCreateRssEndpointFromConfig()

useAstroCreateRssEndpointFromConfig(siteConfig, items): (context) => Promise<Response>

Defined in: src/adapters/astro/rss.service.ts:260

Create an RSS endpoint from a SiteConfig. Reads title, description, site, and rss settings from the config.

Parameters

siteConfig

SiteConfig

Site configuration object

items

RssItem[] | (() => RssItem[] | Promise<RssItem[]>)

RSS items or async factory

Returns

Astro GET handler function

(context) => Promise<Response>

Example

// src/pages/rss.xml.ts
import { useAstroCreateRssEndpointFromConfig } from "katanakit-js/adapters/astro";
import { siteConfig } from "@/config/site.config";
import { getCollection } from "astro:content";

export const GET = useAstroCreateRssEndpointFromConfig(siteConfig, async () => {
const posts = await getCollection("blog");
return posts.map(post => ({
title: post.data.title,
pubDate: post.data.date,
link: `/blog/${post.slug}/`,
}));
});