diff --git a/packages/content-handler/src/websites/the-atlantic-handler.ts b/packages/content-handler/src/websites/the-atlantic-handler.ts index 63920fb59..db61f0a75 100644 --- a/packages/content-handler/src/websites/the-atlantic-handler.ts +++ b/packages/content-handler/src/websites/the-atlantic-handler.ts @@ -10,34 +10,39 @@ export class TheAtlanticHandler extends ContentHandler { shouldPreHandle(url: string): boolean { const u = new URL(url) - return u.hostname.endsWith('theatlantic.com'); + return u.hostname.endsWith('theatlantic.com') } - - unfurlContent(content: Document): Document { - const articleContentSection = content.querySelector('[data-event-module="article body"]'); + unfurlContent(content: Document): Document { + const articleContentSection = content.querySelector( + '[data-event-module="article body"]' + ) if (!articleContentSection) { - return content; + return content } - const divOverArticle = content.createElement("div"); + const divOverArticle = content.createElement('div') divOverArticle.setAttribute('id', 'prehandled') divOverArticle.innerHTML += articleContentSection.innerHTML - content.insertBefore(divOverArticle, articleContentSection); + content.insertBefore(divOverArticle, articleContentSection) - articleContentSection.remove(); + articleContentSection.remove() - return content; + return content } async preHandle(url: string): Promise { - // We simply retrieve the article without Javascript enabled using a GET command. + // We simply retrieve the article without Javascript enabled using a GET command. const response = await axios.get(url) const data = response.data as string const dom = parseHTML(data).document - const editedDom = this.unfurlContent(dom); + const editedDom = this.unfurlContent(dom) - return { content: editedDom.body.outerHTML, title: dom.title, dom: editedDom }; + return { + content: editedDom.body.outerHTML, + title: dom.title, + dom: editedDom, + } } }