fix: handle line-clamp issue with news

This commit is contained in:
2025-10-29 19:59:45 +13:00
parent 14571d23a6
commit 0a52b12f02
2 changed files with 6 additions and 4 deletions

View File

@ -63,17 +63,17 @@ class DiscourseAPI {
* @returns {string} Cleaned excerpt
*/
extractExcerpt(excerpt) {
if (!excerpt) return 'Click to read more...';
if (!excerpt) return 'Click to read more';
// Remove HTML tags and clean up
// Remove HTML tags and clean up; collapse whitespace; do not add manual ellipsis
return excerpt
.replace(/<[^>]*>/g, '') // Remove HTML tags
.replace(/&nbsp;/g, ' ') // Replace &nbsp; with spaces
.replace(/&amp;/g, '&') // Replace &amp; with &
.replace(/&lt;/g, '<') // Replace &lt; with <
.replace(/&gt;/g, '>') // Replace &gt; with >
.replace(/\s+/g, ' ') // Collapse all whitespace/newlines
.trim()
.substring(0, 200) + '...'; // Limit length
}
/**