Skip to content

Commit

Permalink
Use default draft value
Browse files Browse the repository at this point in the history
  • Loading branch information
basham committed Oct 24, 2023
1 parent aa38ad2 commit 88c82f5
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/components/Writings.astro
Original file line number Diff line number Diff line change
Expand Up @@ -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());
---

Expand Down
2 changes: 1 addition & 1 deletion src/content/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
});

Expand Down
2 changes: 1 addition & 1 deletion src/pages/[...slug].astro
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 88c82f5

Please sign in to comment.