From c192cd8e5042d4481bcb0d0389866cf4a969aa8d Mon Sep 17 00:00:00 2001 From: satnaing Date: Sun, 29 Jan 2023 20:08:01 +0630 Subject: [PATCH] fix: exclude draft posts in specific tag page --- src/pages/tags/[tag].astro | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/pages/tags/[tag].astro b/src/pages/tags/[tag].astro index ab9213344..ae3a8ed48 100644 --- a/src/pages/tags/[tag].astro +++ b/src/pages/tags/[tag].astro @@ -16,25 +16,21 @@ export interface Props { } export async function getStaticPaths() { - const posts: CollectionEntry<"blog">[] = await getCollection("blog"); + const posts = await getCollection("blog"); const tags = getUniqueTags(posts); return tags.map(tag => { return { - params: { - tag, - }, - props: { - tag, - }, + params: { tag }, + props: { tag }, }; }); } const { tag } = Astro.props; -const posts: CollectionEntry<"blog">[] = await getCollection("blog"); +const posts = await getCollection("blog", ({ data }) => !data.draft); const tagPosts = getPostsByTag(posts, tag); ---