From 602d141decd3d73c79fbfe8e48ae72c919acaf6e Mon Sep 17 00:00:00 2001 From: Hongbo Wu Date: Thu, 12 May 2022 11:00:32 +0800 Subject: [PATCH] Rename doc to dom --- packages/api/src/utils/parser.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/api/src/utils/parser.ts b/packages/api/src/utils/parser.ts index 878f801b1..06fe8a433 100644 --- a/packages/api/src/utils/parser.ts +++ b/packages/api/src/utils/parser.ts @@ -240,12 +240,12 @@ export const parsePreparedContent = async ( // ...details, // }) // }) - const { document: doc } = parseHTML(document) + const dom = parseHTML(document).document - await applyHandlers(url, doc) + await applyHandlers(url, dom) try { - article = getReadabilityResult(url, document, doc, isNewsletter) + article = getReadabilityResult(url, document, dom, isNewsletter) // Format code blocks // TODO: we probably want to move this type of thing @@ -278,7 +278,7 @@ export const parsePreparedContent = async ( const clean = DOMPurify.sanitize(article?.content || '', DOM_PURIFY_CONFIG) const jsonLdLinkMetadata = (async () => { - return getJSONLdLinkMetadata(doc) + return getJSONLdLinkMetadata(dom) })() Object.assign(article, { @@ -311,7 +311,7 @@ export const parsePreparedContent = async ( domContent: preparedDocument.document, parsedContent: article, canonicalUrl, - pageType: parseOriginalContent(doc), + pageType: parseOriginalContent(dom), } } @@ -358,26 +358,26 @@ type Metadata = { export const parsePageMetadata = (html: string): Metadata | undefined => { try { - const window = parseHTML(html).window + const document = parseHTML(html).document // get open graph metadata const description = - window.document + document .querySelector("head meta[property='og:description']") ?.getAttribute('content') || '' const previewImage = - window.document + document .querySelector("head meta[property='og:image']") ?.getAttribute('content') || '' const title = - window.document + document .querySelector("head meta[property='og:title']") ?.getAttribute('content') || undefined const author = - window.document + document .querySelector("head meta[name='author']") ?.getAttribute('content') || undefined