chore: cleaner truncation
This commit is contained in:
parent
5503730b13
commit
d070830557
2 changed files with 2 additions and 2 deletions
|
@ -64,7 +64,7 @@ export default {
|
|||
},
|
||||
truncateByWordCount: (text, wordCount) => {
|
||||
const words = sanitizeHtml(text, { allowedTags: ['']}).split(/\s+/);
|
||||
if (words.length > wordCount) return `<p>${words.slice(0, wordCount).join(' ')}...</p>`
|
||||
if (words.length > wordCount) return `<p>${words.slice(0, wordCount).join(' ').replace(/[^a-zA-Z0-9]+$/, '')}...</p>`
|
||||
return text
|
||||
},
|
||||
|
||||
|
|
Reference in a new issue