This repository was archived by the owner on Mar 25, 2026. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -13,13 +13,18 @@ interface BlogPostPageProps {
1313}
1414
1515export async function generateStaticParams ( ) {
16- const entries = await getEntriesByCollection ( config . site . slug , 'blog' , {
17- status : 'published'
18- } )
16+ try {
17+ const entries = await getEntriesByCollection ( config . site . slug , 'blog' , {
18+ status : 'published'
19+ } )
1920
20- return entries . map ( ( entry ) => ( {
21- slug : entry . slug
22- } ) )
21+ return entries . map ( ( entry ) => ( {
22+ slug : entry . slug
23+ } ) )
24+ } catch ( error ) {
25+ console . error ( 'Failed to generate static params for blog posts:' , error )
26+ return [ ]
27+ }
2328}
2429
2530export async function generateMetadata ( { params } : BlogPostPageProps ) : Promise < Metadata > {
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import { config } from '@/lib/config'
33import { generatePageMetadata } from '@/lib/metadata'
44import { BlogListing } from '@/components/blog/blog-listing'
55
6- import type { BlogEntryData } from '@/types/rush-cms'
6+ import type { BlogEntryData , RushCMSEntry } from '@/types/rush-cms'
77import type { Metadata } from 'next'
88
99export async function generateMetadata ( ) : Promise < Metadata > {
@@ -18,9 +18,17 @@ export async function generateMetadata(): Promise<Metadata> {
1818}
1919
2020export default async function BlogPage ( ) {
21- const entries = await getEntriesByCollection < BlogEntryData > ( config . site . slug , 'blog' , {
22- status : 'published'
23- } )
21+ let entries : RushCMSEntry < BlogEntryData > [ ] = [ ]
22+
23+ try {
24+ const result = await getEntriesByCollection < BlogEntryData > ( config . site . slug , 'blog' , {
25+ status : 'published'
26+ } )
27+ entries = Array . isArray ( result ) ? result : [ ]
28+ } catch ( error ) {
29+ console . error ( 'Failed to fetch blog entries:' , error )
30+ entries = [ ]
31+ }
2432
2533 return (
2634 < div className = 'w-full max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8 sm:py-12 lg:py-16' >
You can’t perform that action at this time.
0 commit comments