move to cheerio as server side rendering does not support DOMParser

This commit is contained in:
2023-10-10 10:31:56 +02:00
parent 9c5bc00657
commit 7244637ad7
4 changed files with 3191 additions and 5 deletions

View File

@ -1,7 +1,7 @@
// Function to strip HTML tags from a string
function stripHtmlTags(input) {
const parser = new DOMParser();
const doc = parser.parseFromString(input, 'text/html');
const textContent = doc.body.textContent || "";
return textContent;
import {load} from 'cheerio';
export function stripHtmlTags(input) {
const $ = load(input)
return $.text();
}