diff --git a/packages/api/src/services/save_email.ts b/packages/api/src/services/save_email.ts index 2b525c509..860209bf4 100644 --- a/packages/api/src/services/save_email.ts +++ b/packages/api/src/services/save_email.ts @@ -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, diff --git a/packages/api/src/utils/parser.ts b/packages/api/src/utils/parser.ts index 8cb1aeade..54080c4f6 100644 --- a/packages/api/src/utils/parser.ts +++ b/packages/api/src/utils/parser.ts @@ -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