MCPcopy Create free account
hub / github.com/dailydotdev/apps / useTruncatedSummary

Function useTruncatedSummary

packages/shared/src/hooks/useTruncatedSummary.ts:1–18  ·  view source on GitHub ↗
(
  titleProp: string,
  sanitizedSummary?: string,
)

Source from the content-addressed store, hash-verified

1export const useTruncatedSummary = (
2 titleProp: string,
3 sanitizedSummary?: string,
4): { summary?: string; title: string } => {
5 const title =
6 titleProp?.length > 300 ? `${titleProp.slice(0, 300)}...` : titleProp;
7 const maxSummaryLength = Math.max(0, 300 - titleProp?.length || 0);
8 const summary = sanitizedSummary;
9 const truncatedSummary =
10 summary && summary.length > maxSummaryLength
11 ? `${summary.slice(0, maxSummaryLength)}...`
12 : summary;
13
14 return {
15 title,
16 summary: truncatedSummary,
17 };
18};

Callers 10

SquadModerationItemFunction · 0.90
SquadModerationPollFunction · 0.90
SquadModerationDefaultFunction · 0.90
CollectionList.tsxFile · 0.90
FreeformList.tsxFile · 0.90
ShareList.tsxFile · 0.90
ArticleList.tsxFile · 0.90
PollList.tsxFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected