diff --git a/utils.js b/utils.js index 21f087d..03be4c2 100644 --- a/utils.js +++ b/utils.js @@ -84,31 +84,32 @@ export async function getMastodonPost(feedUrl) { // find the first item that isn't a reply (doesn't start with @) for (const item of items) { const description = item.querySelector('description')?.textContent || '' - const title = item.querySelector('title')?.textContent || '' // skip if it's a reply (starts with @ mention) - if (description.trim().startsWith('@') || title.trim().startsWith('@')) { + if (description.trim().startsWith('@')) { continue } const link = item.querySelector('link')?.textContent.trim() - const cleanTitle = sanitizeHtml(title, { + + // use description as the text, stripping HTML + const cleanText = sanitizeHtml(description, { allowedTags: [], allowedAttributes: {}, })?.trim() - return { text: cleanTitle, url: link } + return { text: cleanText, url: link } } // fallback to first item if no non-reply found const firstItem = items[0] - const title = firstItem.querySelector('title').textContent - const link = firstItem.querySelector('link').textContent.trim() - const cleanTitle = sanitizeHtml(title, { + const description = firstItem.querySelector('description')?.textContent || '' + const link = firstItem.querySelector('link')?.textContent.trim() + const cleanText = sanitizeHtml(description, { allowedTags: [], allowedAttributes: {}, })?.trim() - return { text: cleanTitle, url: link } + return { text: cleanText, url: link } } export async function getJsonFeedItemTitle(feedUrl, showImage = true) {