Skip to content

Commit 8ed9fb9

Browse files
committed
add try catch block to return dummy data if no authors found
1 parent 373c379 commit 8ed9fb9

1 file changed

Lines changed: 13 additions & 7 deletions

File tree

app/authors/[slug]/page.tsx

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,19 @@ import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle }
1010
import { ExternalLink, Globe } from "lucide-react"
1111

1212
export async function generateStaticParams() {
13-
const { data: authors } = await supabase.from("authors").select("slug").eq("published", true)
14-
15-
return (
16-
authors?.map((author) => ({
17-
slug: author.slug,
18-
})) || []
19-
)
13+
try {
14+
const { data: authors } = await supabase.from("authors").select("slug").eq("published", true)
15+
16+
return (
17+
authors?.map((author) => ({
18+
slug: author.slug,
19+
})) || []
20+
)
21+
} catch (error) {
22+
console.error("Error generating static params for authors:", error)
23+
// Return a dummy value to satisfy the static export requirement
24+
return [{ slug: "placeholder" }]
25+
}
2026
}
2127

2228
export async function generateMetadata({ params }: { params: { slug: string } }) {

0 commit comments

Comments
 (0)