( titleProp: string, sanitizedSummary?: string, )
| 1 | export 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 | }; |
no outgoing calls
no test coverage detected