diff --git a/src/_data/feeds.ts b/src/_data/feeds.ts index 7c37959..dcfe589 100644 --- a/src/_data/feeds.ts +++ b/src/_data/feeds.ts @@ -74,6 +74,27 @@ const rssFeedUrls = [ // "https://www.webpro.nl/blog/feed.xml", ]; +function getTextFromHtml(htmlString: string): string { + if (!htmlString) { + return ""; + } + + // Remove HTML tags + const withoutTags = htmlString.replace(/<[^>]*>/g, " "); + + // Decode common HTML entities + const decoded = withoutTags + .replace(/ /g, " ") + .replace(/&/g, "&") + .replace(/</g, "<") + .replace(/>/g, ">") + .replace(/"/g, '"') + .replace(/'/g, "'"); + + // Normalize whitespace + return decoded.replace(/\s+/g, " ").trim(); +} + // not all promises are resolved export async function getFeedData() { const addedUrls = new Set(); @@ -97,7 +118,7 @@ export async function getFeedData() { description: item.contentSnippet || item.content || "", link: item.link || "", pubDate: item.pubDate || "", - content: item.content || "", + content: item.content ? getTextFromHtml(item.content) : "", author: item.author || "", }); }