From a9a0d267468ac4933b5c7902e8937bcd9c5b068c Mon Sep 17 00:00:00 2001 From: Huda Joad Date: Sat, 25 Nov 2023 00:26:54 +0300 Subject: [PATCH] added in special handling for headings in simplifyContent() --- netlify/functions/handleMetadata.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/netlify/functions/handleMetadata.js b/netlify/functions/handleMetadata.js index 6ef158c..8499437 100644 --- a/netlify/functions/handleMetadata.js +++ b/netlify/functions/handleMetadata.js @@ -17,6 +17,8 @@ async function fetchContentFromURL(url) { } function simplifyContent(content) { + // Denote headings with a marker (like '###') and add a line break + content = content.replace(/(.*?)<\/h[1-6]>/g, '\n### $1\n'); // Remove script and style elements and their content let simplifiedContent = content.replace(/.*?<\/script>/gms, ''); simplifiedContent = simplifiedContent.replace(/.*?<\/style>/gms, '');