Skip to content

Commit da5cfd3

Browse files
authored
fix: show shared post TLDR for share-type highlights (#5864)
1 parent bb6b60c commit da5cfd3

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

packages/shared/src/components/highlights/HighlightItem.spec.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const highlight: PostHighlightFeed = {
1313
highlightedAt: '2026-04-05T09:00:00.000Z',
1414
post: {
1515
id: 'post-1',
16+
type: 'article',
1617
commentsPermalink: '/posts/post-1',
1718
summary,
1819
},

packages/shared/src/components/highlights/HighlightItem.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import React, { useEffect, useMemo, useRef, useState } from 'react';
33
import classNames from 'classnames';
44
import type { PostHighlightFeed } from '../../graphql/highlights';
55
import { stripHtmlTags } from '../../lib/strings';
6+
import { PostType } from '../../graphql/posts';
67
import { ArrowIcon } from '../icons/Arrow';
78
import { IconSize } from '../Icon';
89
import Link from '../utilities/Link';
@@ -33,18 +34,23 @@ export const HighlightItem = ({
3334
}, [defaultExpanded]);
3435

3536
const tldr = useMemo(() => {
36-
const summary = highlight.post.summary?.trim();
37+
const post =
38+
highlight.post.type === PostType.Share && highlight.post.sharedPost
39+
? highlight.post.sharedPost
40+
: highlight.post;
41+
42+
const summary = post.summary?.trim();
3743
if (summary) {
3844
return summary;
3945
}
4046

41-
const html = highlight.post.contentHtml?.trim();
47+
const html = post.contentHtml?.trim();
4248
if (html) {
4349
return stripHtmlTags(html).slice(0, 300);
4450
}
4551

4652
return '';
47-
}, [highlight.post.summary, highlight.post.contentHtml]);
53+
}, [highlight.post]);
4854

4955
return (
5056
<article ref={ref}>

packages/shared/src/graphql/highlights.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,14 @@ export interface PostHighlightFeed {
2020
highlightedAt: string;
2121
post: {
2222
id: string;
23+
type: string;
2324
commentsPermalink: string;
2425
summary?: string;
2526
contentHtml?: string;
27+
sharedPost?: {
28+
summary?: string;
29+
contentHtml?: string;
30+
};
2631
};
2732
}
2833

@@ -106,9 +111,14 @@ export const POST_HIGHLIGHT_FEED_FRAGMENT = gql`
106111
highlightedAt
107112
post {
108113
id
114+
type
109115
commentsPermalink
110116
summary
111117
contentHtml
118+
sharedPost {
119+
summary
120+
contentHtml
121+
}
112122
}
113123
}
114124
`;

0 commit comments

Comments
 (0)