Skip to content

Commit

Permalink
Igore drafts in production
Browse files Browse the repository at this point in the history
  • Loading branch information
basham committed Oct 23, 2023
1 parent 2ec0e07 commit b285596
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/pages/[...slug].astro
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ import Layout from '@layouts/Layout.astro';
import { slugFromPost } from '@util/slugFromPost';
export async function getStaticPaths() {
const posts = await getCollection('writings');
return posts.map((post) => {
const slug = slugFromPost(post)
return {
params: { slug },
props: post
}
});
return (await getCollection('writings'))
.filter(({ data }) => import.meta.env.PROD ? data.draft !== true : true)
.map((post) => {
const slug = slugFromPost(post)
return {
params: { slug },
props: post
}
});
}
const post = Astro.props;
Expand Down

0 comments on commit b285596

Please sign in to comment.