From a7290eb6bfef137122785cf89f3cc895989f58d2 Mon Sep 17 00:00:00 2001 From: rot1024 Date: Mon, 10 Jun 2024 21:09:39 +0900 Subject: [PATCH] fix: tag rss was failed to be generated --- src/pages/tags/[tag]/rss.xml.ts | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/pages/tags/[tag]/rss.xml.ts b/src/pages/tags/[tag]/rss.xml.ts index ec1a5cd..f6cb91e 100644 --- a/src/pages/tags/[tag]/rss.xml.ts +++ b/src/pages/tags/[tag]/rss.xml.ts @@ -1,12 +1,26 @@ import rss from "@astrojs/rss"; -import defaultClient from "../../../notion"; +import client from "../../../notion"; import { postUrl } from "../../../utils"; +export async function getStaticPaths() { + const posts = await client.getAllPosts(); + const tags = new Set(); + posts.forEach((post) => + post.tags.forEach((tag) => { + tags.add(tag.name); + }), + ); + + return Array.from(tags).map((tag) => ({ + params: { tag }, + })); +} + export async function GET({ params }: { params: { tag: string } }) { const [posts, db] = await Promise.all([ - defaultClient.getAllPosts(), - defaultClient.getDatabase(), + client.getAllPosts(), + client.getDatabase(), ]); return rss({