Skip to content

Commit d857c1e

Browse files
committed
feat: update comment link to use canonical URL in ArticleItem component
1 parent 0ffa7a4 commit d857c1e

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

src/features/cards/components/lobstersCard/ArticleItem.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,13 @@ const ArticleItem = ({ item, analyticsTag }: BaseItemPropsType<Article>) => {
4646
<MdAccessTime className="rowItemIcon" /> {format(new Date(item.published_at))}
4747
</span>
4848
<ClickableItem
49-
link={item.comments_url as string}
49+
link={item.canonical_url || item.url}
5050
className="rowItem rowItemClickable"
5151
analyticsAttributes={{
5252
[Attributes.POINTS]: item.points_count,
5353
[Attributes.TRIGERED_FROM]: 'card',
5454
[Attributes.TITLE]: `${item.title} comments`,
55-
[Attributes.LINK]: item.comments_url,
55+
[Attributes.LINK]: item.canonical_url,
5656
[Attributes.SOURCE]: analyticsTag,
5757
}}>
5858
<BiCommentDetail className="rowItemIcon" /> {item.comments_count} comments

src/features/cards/components/redditCard/ArticleItem.tsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { BsArrowReturnRight } from 'react-icons/bs'
44
import { GoDotFill } from 'react-icons/go'
55
import { MdAccessTime } from 'react-icons/md'
66
import { VscTriangleUp } from 'react-icons/vsc'
7-
import { CardItemWithActions, CardLink } from 'src/components/Elements'
7+
import { CardItemWithActions, CardLink, ClickableItem } from 'src/components/Elements'
88
import { Attributes } from 'src/lib/analytics'
99
import { useUserPreferences } from 'src/stores/preferences'
1010
import { Article, BaseItemPropsType } from 'src/types'
@@ -56,9 +56,18 @@ const ArticleItem = ({ item, analyticsTag }: BaseItemPropsType<Article>) => {
5656
<span className="rowItem">
5757
<MdAccessTime className="rowItemIcon" /> {format(new Date(item.published_at))}
5858
</span>
59-
<span className="rowItem">
59+
<ClickableItem
60+
link={item.canonical_url || item.url}
61+
className="rowItem rowItemClickable"
62+
analyticsAttributes={{
63+
[Attributes.POINTS]: item.points_count,
64+
[Attributes.TRIGERED_FROM]: 'card',
65+
[Attributes.TITLE]: `${item.title} comments`,
66+
[Attributes.LINK]: item.canonical_url,
67+
[Attributes.SOURCE]: analyticsTag,
68+
}}>
6069
<BiCommentDetail className="rowItemIcon" /> {item.comments_count} comments
61-
</span>
70+
</ClickableItem>
6271
{subReddit && (
6372
<span className="rowItem">
6473
<BsArrowReturnRight className="rowItemIcon" /> {`r/${subReddit}`}

0 commit comments

Comments
 (0)