1- import Image from "next/image"
2- import Link from "next/link"
3- import { notFound } from "next/navigation"
4- import { supabase } from "@/lib/supabase"
5- import { downloadImage , ensureImageDirectory } from "@/lib/image-processor"
6- import { renderMarkdown } from "@/lib/markdown"
7- import { Avatar , AvatarFallback , AvatarImage } from "@/components/ui/avatar"
8- import { Button } from "@/components/ui/button"
9- import { Card , CardContent , CardDescription , CardFooter , CardHeader , CardTitle } from "@/components/ui/card"
10- import { ExternalLink , Globe } from "lucide-react"
1+ import Image from "next/image" ;
2+ import Link from "next/link" ;
3+ import { notFound } from "next/navigation" ;
4+ import { supabase } from "@/lib/supabase" ;
5+ import { downloadImage , ensureImageDirectory } from "@/lib/image-processor" ;
6+ import { renderMarkdown } from "@/lib/markdown" ;
7+ import { Avatar , AvatarFallback , AvatarImage } from "@/components/ui/avatar" ;
8+ import { Button } from "@/components/ui/button" ;
9+ import { Card , CardContent , CardDescription , CardFooter , CardHeader , CardTitle } from "@/components/ui/card" ;
10+ import { ExternalLink , Globe } from "lucide-react" ;
1111
1212export async function generateStaticParams ( ) {
1313 try {
14- const { data : authors } = await supabase . from ( "authors" ) . select ( "slug" ) . eq ( "published" , true )
15-
14+ const { data : authors } = await supabase . from ( "authors" ) . select ( "slug" ) . eq ( "published" , true ) ;
15+ console . log ( JSON . stringify ( { authors } , null , 2 ) ) ;
16+ if ( authors ?. length === 0 ) {
17+ return [ { slug : "placeholder" } ] ;
18+ }
1619 return (
1720 authors ?. map ( ( author ) => ( {
1821 slug : author . slug ,
19- } ) ) || [ ]
20- )
22+ } ) ) || [ { slug : "placeholder" } ]
23+ ) ;
2124 } catch ( error ) {
22- console . error ( "Error generating static params for authors:" , error )
25+ console . error ( "Error generating static params for authors:" , error ) ;
2326 // Return a dummy value to satisfy the static export requirement
24- return [ { slug : "placeholder" } ]
27+ return [ { slug : "placeholder" } ] ;
2528 }
2629}
2730
@@ -30,15 +33,15 @@ export async function generateMetadata({ params }: { params: { slug: string } })
3033 . from ( "authors" )
3134 . select ( "name, description, profile_picture" )
3235 . eq ( "slug" , params . slug )
33- . eq ( "published" , true )
36+ . eq ( "published" , true ) ;
3437
35- const author = authors ?. [ 0 ]
38+ const author = authors ?. [ 0 ] ;
3639
3740 if ( ! author ) {
3841 return {
3942 title : "Author Not Found" ,
4043 description : "The requested author could not be found" ,
41- }
44+ } ;
4245 }
4346
4447 return {
@@ -49,37 +52,37 @@ export async function generateMetadata({ params }: { params: { slug: string } })
4952 images : [ { url : author . profile_picture } ] ,
5053 }
5154 : undefined ,
52- }
55+ } ;
5356}
5457
55- export default async function AuthorPage ( { params } : { params : { slug : string } } ) {
58+ export default async function AuthorPage ( { params } : { params : Promise < { slug : string } > } ) {
5659 // Ensure image directory exists (only in Node.js environment)
5760 if ( typeof window === "undefined" ) {
58- ensureImageDirectory ( )
61+ ensureImageDirectory ( ) ;
5962 }
60-
63+ console . log ( "XXXXXXXXXX" , JSON . stringify ( { XXX : await params } , null , 2 ) ) ;
6164 // Fetch the author
6265 const { data : authors , error : authorsError } = await supabase
6366 . from ( "authors" )
6467 . select ( "*" )
65- . eq ( "slug" , params . slug )
66- . eq ( "published" , true )
68+ . eq ( "slug" , ( await params ) . slug )
69+ . eq ( "published" , true ) ;
6770
6871 if ( authorsError || ! authors || authors . length === 0 ) {
69- notFound ( )
72+ notFound ( ) ;
7073 }
7174
72- const author = authors [ 0 ]
75+ const author = authors [ 0 ] ;
7376
7477 // Process profile picture if it exists
7578 if ( author . profile_picture && typeof window === "undefined" ) {
76- author . profile_picture = ( await downloadImage ( author . profile_picture ) ) || author . profile_picture
79+ author . profile_picture = ( await downloadImage ( author . profile_picture ) ) || author . profile_picture ;
7780 }
7881
7982 // Process bio if it exists
80- let bioHtml = null
83+ let bioHtml = null ;
8184 if ( author . bio ) {
82- bioHtml = await renderMarkdown ( author . bio )
85+ bioHtml = await renderMarkdown ( author . bio ) ;
8386 }
8487
8588 // Fetch author's posts
@@ -88,17 +91,17 @@ export default async function AuthorPage({ params }: { params: { slug: string }
8891 . select ( "*" )
8992 . eq ( "author_id" , author . id )
9093 . eq ( "published" , true )
91- . order ( "created_at" , { ascending : false } )
94+ . order ( "created_at" , { ascending : false } ) ;
9295
9396 // Process post cover images
9497 const processedPosts = await Promise . all (
9598 ( posts || [ ] ) . map ( async ( post ) => {
9699 if ( post . cover_image && typeof window === "undefined" ) {
97- post . cover_image = ( await downloadImage ( post . cover_image ) ) || post . cover_image
100+ post . cover_image = ( await downloadImage ( post . cover_image ) ) || post . cover_image ;
98101 }
99- return post
100- } ) ,
101- )
102+ return post ;
103+ } )
104+ ) ;
102105
103106 return (
104107 < div className = "space-y-12" >
@@ -191,6 +194,5 @@ export default async function AuthorPage({ params }: { params: { slug: string }
191194 ) }
192195 </ div >
193196 </ div >
194- )
197+ ) ;
195198}
196-
0 commit comments