mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Add GitHubHandler class
This commit is contained in:
parent
f39c6923b0
commit
ff21770a70
1 changed files with 23 additions and 0 deletions
23
packages/content-handler/src/websites/github-handler.ts
Normal file
23
packages/content-handler/src/websites/github-handler.ts
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
import { ContentHandler } from '../content-handler'
|
||||
|
||||
export class GitHubHandler extends ContentHandler {
|
||||
constructor() {
|
||||
super()
|
||||
this.name = 'github'
|
||||
}
|
||||
|
||||
shouldPreParse(url: string, dom: Document): boolean {
|
||||
return new URL(url).hostname.endsWith('github.com')
|
||||
}
|
||||
|
||||
async preParse(url: string, dom: Document): Promise<Document> {
|
||||
const body = dom.querySelector('body')
|
||||
const article = dom.querySelector('article')
|
||||
|
||||
if (body && article) {
|
||||
body?.replaceChildren(article)
|
||||
}
|
||||
|
||||
return Promise.resolve(dom)
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue