Skip to content

Commit

Permalink
feat: add draft status to blog post schema for default false
Browse files Browse the repository at this point in the history
  • Loading branch information
colmugx committed Sep 9, 2024
1 parent aa20338 commit 894c9d8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/content/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const blog = defineCollection({
// Type-check frontmatter using a schema
schema: z
.object({
draft: z.boolean().default(false),
title: z.string(),
subTitle: z.string().optional(),
category: z.string().optional(),
Expand Down
4 changes: 3 additions & 1 deletion src/service/post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ class PostService {

private async getData() {
if (!this.data.length) {
this.data = await getCollection('blog')
const data = await getCollection('blog')

this.data = data.filter(item => !item.data.draft)
}

return this.data
Expand Down

0 comments on commit 894c9d8

Please sign in to comment.