Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion __tests__/PostPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ it('should set href to the post permalink', async () => {
const res = renderPost();
// Wait for GraphQL to return
await res.findByText('Learn SQL');
const el = res.getByTitle('Go to article');
const el = res.getAllByTitle('Go to article')[0];
expect(el).toHaveAttribute('href', 'http://localhost:4000/r/9CuRpr5NiEY5');
});

Expand Down
36 changes: 21 additions & 15 deletions pages/posts/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,12 @@ const Tags = styled.div`
${typoSmall};
`;

const PostImage = styled(LazyImage)`
const PostImage = styled.a`
display: block;
margin: ${size2} 0;
border-radius: ${size4};
overflow: hidden;
cursor: pointer;
`;

const ActionButtons = styled.div`
Expand Down Expand Up @@ -410,6 +413,14 @@ export default function PostPage({ id }: Props): ReactElement {
}
};

const postLinkProps = {
href: postById?.post.permalink,
title: 'Go to article',
target: '_blank',
rel: 'noopener noreferrer',
onClick: () => ReactGA.event({ category: 'Post', action: 'Click' }),
};

const Seo: NextSeoProps = {
title: postById?.post.title,
description: `Join us to the discussion about "${postById?.post.title}" on daily.dev ✌️`,
Expand Down Expand Up @@ -455,25 +466,20 @@ export default function PostPage({ id }: Props): ReactElement {
)}
</MetadataContainer>
</PostInfoSubContainer>
<IconButton
as="a"
href={postById?.post.permalink}
title="Go to article"
target="_blank"
rel="noopener noreferrer"
onClick={() => ReactGA.event({ category: 'Post', action: 'Click' })}
>
<IconButton as="a" {...postLinkProps}>
<OpenLinkIcon />
</IconButton>
</PostInfo>
<Title>{postById?.post.title}</Title>
<Tags>{postById?.post.tags.map((t) => `#${t}`).join(' ')}</Tags>
<PostImage
imgSrc={postById?.post.image}
imgAlt="Post cover image"
lowsrc={postById?.post.placeholder}
ratio="49%"
/>
<PostImage {...postLinkProps}>
<LazyImage
imgSrc={postById?.post.image}
imgAlt="Post cover image"
lowsrc={postById?.post.placeholder}
ratio="49%"
/>
</PostImage>
<ActionButtons>
<FloatButton
done={postById?.post.upvoted}
Expand Down