Skip to content

Commit

Permalink
Add support for draft status on projects
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonappah committed Jun 9, 2024
1 parent 621d4b5 commit cd74c9e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/content/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const projectCollection = defineCollection({
deprecated: z.boolean().default(false),
stats: z.array(statSchema),
mainImage: z.object({ src: z.string(), alt: z.string() }),
draft: z.boolean().default(false)
}),
})

Expand Down
6 changes: 4 additions & 2 deletions src/pages/projects/[...slug].astro
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import Join from '../../components/join.astro'
import { getCollection } from 'astro:content'
export async function getStaticPaths() {
const projectEntries = await getCollection('projects')
console.log({ projectEntries })
const projectEntries = await getCollection('projects', ({ data }) => {
return import.meta.env.PROD ? data.draft !== true : true
})
return projectEntries.map((entry) => ({
params: { slug: entry.slug },
props: { entry },
Expand Down

0 comments on commit cd74c9e

Please sign in to comment.