feat: drafts frontmatter & exclude drafts from production
This commit is contained in:
parent
bfd3bef223
commit
ca28bd2d36
12 changed files with 34 additions and 11 deletions
|
@ -17,7 +17,9 @@ const t = useTranslations(lang);
|
|||
const translatePath = useTranslatedPath(lang);
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const blogEntries = await getCollection('posts');
|
||||
const blogEntries = await getCollection('posts', ({ data }) => {
|
||||
return import.meta.env.PROD ? data.draft !== true : true;
|
||||
});
|
||||
return blogEntries.map(entry => ({
|
||||
params: { slug: entry.slug }, props: { entry },
|
||||
}));
|
||||
|
|
|
@ -2,7 +2,9 @@ import { getCollection } from 'astro:content';
|
|||
|
||||
export const prerender = true;
|
||||
export async function getStaticPaths() {
|
||||
const blogEntries = await getCollection('posts');
|
||||
const blogEntries = await getCollection('posts', ({ data }) => {
|
||||
return import.meta.env.PROD ? data.draft !== true : true;
|
||||
});
|
||||
return blogEntries.map(entry => ({
|
||||
params: { slug: entry.slug }, props: { entry },
|
||||
}));
|
||||
|
|
|
@ -62,7 +62,9 @@ const fileCache = {
|
|||
};
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const blogEntries = await getCollection('posts');
|
||||
const blogEntries = await getCollection('posts', ({ data }) => {
|
||||
return import.meta.env.PROD ? data.draft !== true : true;
|
||||
});
|
||||
return blogEntries.map(post => ({
|
||||
params: { slug: post.slug }, props: { post },
|
||||
}));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue