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
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const highlight: PostHighlightFeed = {
highlightedAt: '2026-04-05T09:00:00.000Z',
post: {
id: 'post-1',
type: 'article',
commentsPermalink: '/posts/post-1',
summary,
},
Expand Down
12 changes: 9 additions & 3 deletions packages/shared/src/components/highlights/HighlightItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React, { useEffect, useMemo, useRef, useState } from 'react';
import classNames from 'classnames';
import type { PostHighlightFeed } from '../../graphql/highlights';
import { stripHtmlTags } from '../../lib/strings';
import { PostType } from '../../graphql/posts';
import { ArrowIcon } from '../icons/Arrow';
import { IconSize } from '../Icon';
import Link from '../utilities/Link';
Expand Down Expand Up @@ -33,18 +34,23 @@ export const HighlightItem = ({
}, [defaultExpanded]);

const tldr = useMemo(() => {
const summary = highlight.post.summary?.trim();
const post =
highlight.post.type === PostType.Share && highlight.post.sharedPost
? highlight.post.sharedPost
: highlight.post;

const summary = post.summary?.trim();
if (summary) {
return summary;
}

const html = highlight.post.contentHtml?.trim();
const html = post.contentHtml?.trim();
if (html) {
return stripHtmlTags(html).slice(0, 300);
}

return '';
}, [highlight.post.summary, highlight.post.contentHtml]);
}, [highlight.post]);

return (
<article ref={ref}>
Expand Down
10 changes: 10 additions & 0 deletions packages/shared/src/graphql/highlights.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,14 @@ export interface PostHighlightFeed {
highlightedAt: string;
post: {
id: string;
type: string;
commentsPermalink: string;
summary?: string;
contentHtml?: string;
sharedPost?: {
summary?: string;
contentHtml?: string;
};
};
}

Expand Down Expand Up @@ -106,9 +111,14 @@ export const POST_HIGHLIGHT_FEED_FRAGMENT = gql`
highlightedAt
post {
id
type
commentsPermalink
summary
contentHtml
sharedPost {
summary
contentHtml
}
}
}
`;
Expand Down
Loading