Updated sanitization and truncation of article previews

This commit is contained in:
itzMiney committed 2025-08-18 21:44:53 +02:00
1 parent 5bbadfef1c
commit 6986c67494
2 files changed
+11 -1

No files matched your search

+10
View File
@@ -75,4 +75,14 @@ export class BlogComponent implements OnInit, OnDestroy, AfterViewInit {
onResize() {
this.vantaService.resizeVanta(this.elementId);
}
sanitizeContent(content: string): string {
if (!content) return '';
return content.replace(/<[^>]*>/g, ' ').replace(/\s+/g, ' ').trim();
}
truncateContent(content: string, length: number): string {
const sanitized = this.sanitizeContent(content);
return sanitized.length > length ? sanitized.slice(0, length) + '...' : sanitized;
}
}