Skip to content

Commit

Permalink
Added links back to BlogPostItem
Browse files Browse the repository at this point in the history
  • Loading branch information
akshatnema committed Oct 11, 2024
1 parent 6b30619 commit 3a87764
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 7 deletions.
15 changes: 14 additions & 1 deletion components/Avatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,18 @@ export default function Avatar({ name, photo, link, className }: AvatarProps) {
/>
);

return link ? <span data-testid='Avatars-link'>{avatar}</span> : <React.Fragment>{avatar}</React.Fragment>;
return link ? (
<span
onClick={(e) => {
e.preventDefault();

window.open(link, '_blank');
}}
data-testid='Avatars-link'
>
{avatar}
</span>
) : (
<React.Fragment>{avatar}</React.Fragment>
);
}
15 changes: 12 additions & 3 deletions components/navigation/BlogPostItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,24 @@ export default forwardRef(function BlogPostItem(
{post.authors
.map((author, index) =>
author.link ? (
<span key={index} data-alt={author.name}>
<span
key={index}
data-alt={author.name}
onClick={(e) => {
e.preventDefault();

// Handle the click event, e.g., navigate to author.link
window.open(author.link, '_blank');
}}
>
{author.name}
</span>
) : (
author.name
)
)
.reduce((prev, curr) => (
<React.Fragment>
.reduce((prev, curr, index) => (
<React.Fragment key={`author-${index}`}>
{prev} & {curr}
</React.Fragment>
))}
Expand Down
2 changes: 1 addition & 1 deletion next-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
// see https://nextjs.org/docs/pages/building-your-application/configuring/typescript for more information.
4 changes: 2 additions & 2 deletions pages/blog/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ export default function BlogIndexPage() {
const image = '/img/social/blog.webp';

useEffect(() => {
setIsClient(router.isReady);
}, [router.isReady]);
setIsClient(true);
}, []);

return (
<GenericLayout title='Blog' description={description} image={image} wide>
Expand Down

0 comments on commit 3a87764

Please sign in to comment.