mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Fetch title and author from page metadate if possible
This commit is contained in:
parent
b17f22949c
commit
c2e08d0e8f
2 changed files with 19 additions and 3 deletions
|
|
@ -50,8 +50,9 @@ export const saveEmail = async (
|
|||
originalHtml: input.originalContent,
|
||||
content: content,
|
||||
description: metadata?.description || parseResult.parsedContent?.excerpt,
|
||||
title: parseResult.parsedContent?.title || title,
|
||||
author: parseResult.parsedContent?.byline || input.author,
|
||||
title: metadata?.title || parseResult.parsedContent?.title || title,
|
||||
author:
|
||||
metadata?.author || parseResult.parsedContent?.byline || input.author,
|
||||
url: normalizeUrl(parseResult.canonicalUrl || url, {
|
||||
stripHash: true,
|
||||
stripWWW: false,
|
||||
|
|
|
|||
|
|
@ -346,6 +346,8 @@ const getJSONLdLinkMetadata = async (
|
|||
}
|
||||
|
||||
type Metadata = {
|
||||
title?: string
|
||||
author?: string
|
||||
description: string
|
||||
previewImage: string
|
||||
}
|
||||
|
|
@ -368,7 +370,20 @@ export const parseMetadata = async (
|
|||
.querySelector("head meta[property='og:image']")
|
||||
?.getAttribute('content') || ''
|
||||
|
||||
return { description: description, previewImage: previewImage }
|
||||
const title =
|
||||
window.document
|
||||
.querySelector("head meta[property='og:title']")
|
||||
?.getAttribute('content') || undefined
|
||||
|
||||
const author =
|
||||
window.document
|
||||
.querySelector("head meta[property='author']")
|
||||
?.getAttribute('content') || undefined
|
||||
|
||||
// TODO: we should be able to apply the JSONLD metadata
|
||||
// here too
|
||||
|
||||
return { title, author, description, previewImage }
|
||||
} catch (e) {
|
||||
console.log('failed to got:', url, e)
|
||||
return undefined
|
||||
|
|
|
|||
Loading…
Reference in a new issue