diff --git a/src/components/Writings.astro b/src/components/Writings.astro index 6f8bbc9..7bdd28b 100644 --- a/src/components/Writings.astro +++ b/src/components/Writings.astro @@ -3,7 +3,7 @@ import { getCollection } from 'astro:content'; import { slugFromPost } from '@util/slugFromPost'; const posts = (await getCollection('writings')) - .filter(({ data }) => import.meta.env.PROD ? data.draft !== true : true) + .filter(({ data }) => import.meta.env.PROD ? !data.draft : true) .sort((a, b) => b.data.pubDate.valueOf() - a.data.pubDate.valueOf()); --- diff --git a/src/content/config.ts b/src/content/config.ts index 1f94c17..b769681 100644 --- a/src/content/config.ts +++ b/src/content/config.ts @@ -7,7 +7,7 @@ const writings = defineCollection({ pubDate: z.date().transform((d) => new Date(d.getTime() + Math.abs(d.getTimezoneOffset() * 60000)) ), - draft: z.boolean().optional() + draft: z.boolean().optional().default(false) }) }); diff --git a/src/pages/[...slug].astro b/src/pages/[...slug].astro index f3c1b1b..3215fde 100644 --- a/src/pages/[...slug].astro +++ b/src/pages/[...slug].astro @@ -5,7 +5,7 @@ import { slugFromPost } from '@util/slugFromPost'; export async function getStaticPaths() { return (await getCollection('writings')) - .filter(({ data }) => import.meta.env.PROD ? data.draft !== true : true) + .filter(({ data }) => import.meta.env.PROD ? !data.draft : true) .map((post) => { const slug = slugFromPost(post) return {