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
}
/**

View File

@ -192,7 +192,9 @@
${topic.title}
</a>
</h3>
<p class="text-sm line-clamp-4 mb-2 h-20 text-ellipsis wrap-break-word overflow-hidden">${topic.excerpt}</p>
<div class="text-sm line-clamp-4 break-words" >
${topic.excerpt}
</div>
<div class="flex flex-row items-center justify-between">
<div class="flex items-center gap-2">