diff --git a/src/components/AddBookmarkModal.tsx b/src/components/AddBookmarkModal.tsx index 3a8325ee..1063182e 100644 --- a/src/components/AddBookmarkModal.tsx +++ b/src/components/AddBookmarkModal.tsx @@ -43,31 +43,66 @@ const AddBookmarkModal: React.FC = ({ onClose, onSave }) try { const metadata = await fetchReadableContent(parsedUrl.toString()) - // Only auto-fill if fields are empty - if (metadata.title && !title) { - setTitle(metadata.title) - } - - // Try to extract description from markdown or HTML - if (!description) { - let extractedDesc = '' - if (metadata.markdown) { - // Take first paragraph from markdown - const firstPara = metadata.markdown.split('\n\n')[0] - extractedDesc = firstPara.replace(/^#+\s*/g, '').trim().slice(0, 200) - } else if (metadata.html) { - // Try to extract meta description or first paragraph - const metaMatch = metadata.html.match(/ tag - const pMatch = metadata.html.match(/]*>(.*?)<\/p>/is) - if (pMatch) { - extractedDesc = pMatch[1].replace(/<[^>]+>/g, '').trim().slice(0, 200) - } + // Extract title: prioritize og:title, then regular title + let extractedTitle = '' + if (metadata.html) { + // Try OpenGraph title first + const ogTitleMatch = metadata.html.match(/ tag + const pMatch = metadata.html.match(/]*>(.*?)<\/p>/is) + if (pMatch) { + extractedDesc = pMatch[1].replace(/<[^>]+>/g, '').trim().slice(0, 200) + } + } + } + } + } else if (metadata.markdown) { + // For markdown, take first paragraph + const firstPara = metadata.markdown.split('\n\n')[0] + extractedDesc = firstPara.replace(/^#+\s*/g, '').trim().slice(0, 200) + } + if (extractedDesc) { setDescription(extractedDesc) }