File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ import { read } from 'gray-matter'
88import { safeParse } from 'valibot'
99import { BlogPostSchema , type BlogPostFrontmatter } from '../shared/schemas/blog'
1010import { globSync } from 'tinyglobby'
11+ import { isProduction } from '../config/env'
1112
1213/**
1314 * Scans the blog directory for .md files and extracts validated frontmatter.
@@ -75,13 +76,13 @@ export default defineNuxtModule({
7576 } ) ,
7677 )
7778
78- // Expose frontmatter for published (non-draft) posts to avoid bundling the
79- // full content of all posts in the `/blog` listing page.
79+ // Expose frontmatter for the `/blog` listing page.
80+ const showDrafts = nuxt . options . dev || ! isProduction
8081 addTemplate ( {
8182 filename : 'blog/posts.ts' ,
8283 write : true ,
8384 getContents : ( ) => {
84- const posts = loadBlogPosts ( blogDir ) . filter ( p => ! p . draft )
85+ const posts = loadBlogPosts ( blogDir ) . filter ( p => showDrafts || ! p . draft )
8586 return [
8687 `import type { BlogPostFrontmatter } from '#shared/schemas/blog'` ,
8788 `` ,
You can’t perform that action at this time.
0 commit comments