diff --git a/components/AuthorMapping.tsx b/components/AuthorMapping.tsx index 975e301..0bff74c 100644 --- a/components/AuthorMapping.tsx +++ b/components/AuthorMapping.tsx @@ -7,7 +7,7 @@ export default function AuthorMapping({ AuthorArray, itemsPerPage = 8, // You can customize the number of items per page }:{ - AuthorArray: Pick[], + AuthorArray: Pick[], itemsPerPage?:number }) { const [currentPage, setCurrentPage] = useState(1); @@ -17,7 +17,7 @@ export default function AuthorMapping({ AuthorArray.forEach((item) => { const ppmaAuthorName = formatAuthorName(item.ppmaAuthorName); - const avatarUrl = item.author.node.avatar.url; + const avatarUrl = item.ppmaAuthorImage; const slug = item.ppmaAuthorName; const publishingAuthor = formatAuthorName(item.author.node.name); if (Array.isArray(ppmaAuthorName)) { @@ -66,8 +66,7 @@ export default function AuthorMapping({
- {author.publishingAuthor.split(" ")[0].toLowerCase().trim() == - author.ppmaAuthorName.split(" ")[0].toLowerCase().trim() ? ( + {author.avatarUrl != "imag1" && author.avatarUrl != "image" ? ( {`${author.ppmaAuthorName}'s { - const { slug } = params; - const postsByAuthor = await getPostsByAuthor(); - const filteredPosts = postsByAuthor.edges.filter( + const { slug } = params as { slug: string }; + + // Fetch posts from both sources + const postsByTechnology = await getAllPostsForTechnology(preview); + const postsByCommunity = await getAllPostsForCommunity(preview); + + // Combine posts from both sources + const allPosts = [...postsByTechnology.edges, ...postsByCommunity.edges]; + + // Filter the combined posts by the given slug + const filteredPosts = allPosts.filter( (item) => item.node.ppmaAuthorName === slug ); - const postId = (filteredPosts[0].node.postId); - const content = await getContent(postId); + + // Extract postId from the first matching post (if any) + const postId = filteredPosts[0]?.node?.postId; + + // Fetch content using postId (if available) + const content = postId ? await getContent(postId) : null; return { - props: { preview, filteredPosts , content}, - revalidate: 10, + props: { preview, filteredPosts, content }, + revalidate: 10, // ISR with 10 seconds revalidation }; }; diff --git a/pages/authors/index.tsx b/pages/authors/index.tsx index 4c955e9..8b4d468 100644 --- a/pages/authors/index.tsx +++ b/pages/authors/index.tsx @@ -13,7 +13,7 @@ export default function Authors({ }: { AllAuthors: { edges: { - node: { author: Post["author"]; ppmaAuthorName: Post["ppmaAuthorName"] }; + node: { author: Post["author"]; ppmaAuthorName: Post["ppmaAuthorName"],ppmaAuthorImage: Post["ppmaAuthorImage"] }; }[]; }; preview; @@ -42,6 +42,7 @@ export default function Authors({ export const getStaticProps: GetStaticProps = async ({ preview = false }) => { const AllAuthors = await getAllAuthors(); + console.log(AllAuthors.edges); return { props: { AllAuthors, preview }, revalidate: 10, diff --git a/types/post.ts b/types/post.ts index df5d925..606e629 100644 --- a/types/post.ts +++ b/types/post.ts @@ -6,6 +6,7 @@ export interface Post { excerpt: string; slug: string; date: string; + postId: Number; featuredImage: { node: { sourceUrl: string; @@ -15,6 +16,7 @@ export interface Post { node: Author; }; ppmaAuthorName: string; + ppmaAuthorImage: string; categories: { edges: { node: {