diff options
Diffstat (limited to 'src/build/static.ts')
-rw-r--r-- | src/build/static.ts | 28 |
1 files changed, 0 insertions, 28 deletions
diff --git a/src/build/static.ts b/src/build/static.ts deleted file mode 100644 index af99c33cb..000000000 --- a/src/build/static.ts +++ /dev/null @@ -1,28 +0,0 @@ -import type { Element } from 'domhandler'; -import cheerio from 'cheerio'; - -/** Given an HTML string, collect <link> and <img> tags */ -export function collectStatics(html: string) { - const statics = new Set<string>(); - - const $ = cheerio.load(html); - - const append = (el: Element, attr: string) => { - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - const value: string = $(el).attr(attr)!; - if (value.startsWith('http') || $(el).attr('rel') === 'alternate') { - return; - } - statics.add(value); - }; - - $('link[href]').each((i, el) => { - append(el, 'href'); - }); - - $('img[src]').each((i, el) => { - append(el, 'src'); - }); - - return statics; -} |