diff options
| author | Dawid Rycerz <dawid@rycerz.xyz> | 2025-07-04 01:00:29 +0300 |
|---|---|---|
| committer | Dawid Rycerz <dawid@rycerz.xyz> | 2025-07-04 01:00:29 +0300 |
| commit | 1686b0a7cafc8b58929c10f889783286322892df (patch) | |
| tree | 157b6d45697dd2eb2ad8f10caab207a6bef0de93 /src/data/post.ts | |
| parent | 3f0373ee3c64d80af91ebcbcca37ebdc1ae3de8a (diff) | |
Migrate old content
Diffstat (limited to 'src/data/post.ts')
| -rw-r--r-- | src/data/post.ts | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/data/post.ts b/src/data/post.ts index 87e0b01..c7df82f 100644 --- a/src/data/post.ts +++ b/src/data/post.ts @@ -1,9 +1,11 @@ import { type CollectionEntry, getCollection } from "astro:content"; -/** filter out draft posts based on the environment */ -export async function getAllPosts(): Promise<CollectionEntry<"post">[]> { +/** filter out draft posts based on the environment and optionally archived posts */ +export async function getAllPosts(includeArchived = false): Promise<CollectionEntry<"post">[]> { return await getCollection("post", ({ data }) => { - return import.meta.env.PROD ? !data.draft : true; + const isDraftFilter = import.meta.env.PROD ? !data.draft : true; + const isArchivedFilter = includeArchived || !data.tags.includes("archived"); + return isDraftFilter && isArchivedFilter; }); } |
