File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed
Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -13,18 +13,20 @@ type BlogPostPageProps = {
1313 } > ;
1414} ;
1515
16- export const dynamicParams = false ;
16+ const isDev = process . env . NODE_ENV === "development" ;
17+
18+ export const dynamicParams = isDev ;
1719
1820export async function generateStaticParams ( ) {
19- const slugs = await getAllSlugs ( ) ;
21+ const slugs = await getAllSlugs ( { includeUnpublished : isDev } ) ;
2022 return slugs . map ( ( slug ) => ( { slug } ) ) ;
2123}
2224
2325export async function generateMetadata ( {
2426 params,
2527} : BlogPostPageProps ) : Promise < Metadata > {
2628 const { slug } = await params ;
27- const post = await getPostBySlug ( slug ) ;
29+ const post = await getPostBySlug ( slug , { includeUnpublished : isDev } ) ;
2830
2931 if ( ! post ) {
3032 return { } ;
@@ -58,7 +60,7 @@ export async function generateMetadata({
5860
5961export default async function BlogPostPage ( { params } : BlogPostPageProps ) {
6062 const { slug } = await params ;
61- const post = await getPostBySlug ( slug ) ;
63+ const post = await getPostBySlug ( slug , { includeUnpublished : isDev } ) ;
6264
6365 if ( ! post ) {
6466 notFound ( ) ;
You can’t perform that action at this time.
0 commit comments