This commit is contained in:
Adam Matthiesen 2024-02-21 05:06:23 -08:00
parent 517081a1e8
commit e2438684f7
4 changed files with 33 additions and 0 deletions

View File

@ -63,6 +63,7 @@
"vitest-fetch-mock": "^0.2.2"
},
"dependencies": {
"@astrojs/rss": "^4.0.5",
"@ts-ghost/core-api": "^5.1.2",
"vite": "^5.1.2",
"vite-tsconfig-paths": "^4.2.2"

View File

@ -0,0 +1,25 @@
import rss from "@astrojs/rss";
import type { APIContext } from "astro";
import { getAllPosts } from "../utils/api";
const posts = await getAllPosts();
import config from 'virtual:starlight-ghost-config'
export async function GET({ site }: APIContext) {
const title = config.title;
const description = config.rssDescription;
return rss({
title: title,
description: description,
site: site,
items: posts.map((post) => ({
title: post.title,
pubDate: new Date(
post.published_at ? post.published_at : post.created_at,
),
description: post.excerpt,
link: `/blog/${post.slug}/`,
author: post.primary_author?.name,
})),
});
}

View File

@ -15,6 +15,10 @@ const configSchema = z
* The title of the blog.
*/
title: z.string().default('Blog'),
/**
* The description of the blog on the RSS Feed.
*/
rssDescription: z.string(),
/**
* Turn on and off "Powered by Ghost"
*/

View File

@ -304,6 +304,9 @@ importers:
packages/starlight-ghostcms:
dependencies:
'@astrojs/rss':
specifier: ^4.0.5
version: 4.0.5
'@ts-ghost/core-api':
specifier: ^5.1.2
version: 5.1.2