import React from 'react'; import PostCard from '@/components/PostCard'; import { getPostsByAuthor } from '@/lib/posts'; import { getAllAuthors } from '@/lib/authors'; import { PostMetadata } from '@/types'; import { generateMetadata as createMetadata } from '@/components/Metadata'; import type { Metadata } from 'next'; import AuthorProfile from './AuthorProfile'; interface PageProps { params: Promise<{ author: string }>; } export async function generateStaticParams() { const authors = await getAllAuthors(); return authors.map((author) => ({ author: author.slug, })); } export async function generateMetadata({ params }: PageProps): Promise { const { author } = await params; const decodedAuthor = decodeURIComponent(author); return createMetadata({ title: `${decodedAuthor} | Author`, description: `Posts authored by ${decodedAuthor} on Confessions of Grace.`, url: `https://confessionsofgrace.com/authors/${author}`, type: 'website' }); } async function getPostsByAuthorData(author: string): Promise { return await getPostsByAuthor(author); } export default async function AuthorPage({ params }: PageProps) { const { author } = await params; const decodedAuthor = decodeURIComponent(author); const posts = await getPostsByAuthorData(decodedAuthor); return (
{/* Posts */}

{posts.length} {posts.length === 1 ? 'post' : 'posts'} authored by "{decodedAuthor}"

{posts.length > 0 ? (
{posts.map((post) => ( ))}
) : (

No posts found for this author.

)}
); }