Skip to content

Commit

Permalink
Treat hidden DOM elements before treating media files.
Browse files Browse the repository at this point in the history
  • Loading branch information
pavel-karatsiuba authored and kelson42 committed Feb 18, 2023
1 parent 993cdd9 commit e350e43
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions src/util/saveArticles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,19 @@ async function processArticleHtml(
let mediaDependencies: Array<{ url: string; path: string }> = []
let subtitles: Array<{ url: string; path: string }> = []
let doc = domino.createDocument(html)

const ruRet = await rewriteUrlsOfDoc(doc, articleId, redisStore, mw, dump)
doc = ruRet.doc
mediaDependencies = mediaDependencies.concat(
ruRet.mediaDependencies
.filter((a) => a)
.map((url) => {
const path = getMediaBase(url, false)
return { url, path }
}),
)
doc = applyOtherTreatments(doc, dump)

const tmRet = await treatMedias(doc, mw, dump, articleId, webp, redisStore)
doc = tmRet.doc

Expand All @@ -454,17 +467,6 @@ async function processArticleHtml(
return { url, path }
}),
)
const ruRet = await rewriteUrlsOfDoc(doc, articleId, redisStore, mw, dump)
doc = ruRet.doc
mediaDependencies = mediaDependencies.concat(
ruRet.mediaDependencies
.filter((a) => a)
.map((url) => {
const path = getMediaBase(url, false)
return { url, path }
}),
)
doc = applyOtherTreatments(doc, dump)

if (!dump.isMainPage(articleId) && dump.customProcessor?.preProcessArticle) {
doc = await dump.customProcessor.preProcessArticle(articleId, doc)
Expand Down

0 comments on commit e350e43

Please sign in to comment.