From 801e2bec25cb477cc6f1a32479fb4c62208143e8 Mon Sep 17 00:00:00 2001 From: Martin Grubinger Date: Fri, 13 Jan 2023 10:59:04 +0100 Subject: [PATCH] remove test --- .gitignore | 1 + test/+page.server.js | 55 -------------------------------------------- test/+page.svelte | 20 ---------------- 3 files changed, 1 insertion(+), 75 deletions(-) delete mode 100644 test/+page.server.js delete mode 100644 test/+page.svelte diff --git a/.gitignore b/.gitignore index fcb5151..5f5e3d9 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ node_modules .vercel .output .vscode +top10test \ No newline at end of file diff --git a/test/+page.server.js b/test/+page.server.js deleted file mode 100644 index 45f32bb..0000000 --- a/test/+page.server.js +++ /dev/null @@ -1,55 +0,0 @@ -import { error } from '@sveltejs/kit'; -import { JSDOM } from 'jsdom'; - -// TODO: to make this work on vercel, adjust like this: https://github.com/Automattic/node-canvas/issues/1779 - - -let baseUrl = 'http://ogimage.ghwb/'; -let baseUrlPostfix = '?gh_beta=ogimage'; - - -/** @type {import('./$types').PageServerLoad} */ -export async function load({}) { - let dom = await fetchPageAsDom(baseUrl); - - // console.log(dom.window.document.querySelector('.secondary-nav-item.deals-link').textContent); // "Hello world" - let top10links = dom.window.document.querySelectorAll('#gh_m_top .line-clamp a'); - - let images = await getImages(top10links); - - images = images.map(i => { - return i.replace('https://geizhals-og-image.vercel.app', 'http://localhost:5173') - }); - - return { - images - }; - - throw error(404, 'Not found'); -} - -async function getImages(links) { - let collectedImages = []; - - let promises = [...links].map((link) => { - return fetchPageAsDom(baseUrl + link + baseUrlPostfix); - }); - - let results = await Promise.all(promises); - - results.forEach((pageDOM) => { - let image = pageDOM.window.document - .querySelector('meta[property="og:image"]') - .getAttribute('content'); - collectedImages.push(image); - }); - - return collectedImages; -} - -async function fetchPageAsDom(url) { - let r = await fetch(url); - let text = await r.text(); - let dom = new JSDOM(text); - return dom; -} diff --git a/test/+page.svelte b/test/+page.svelte deleted file mode 100644 index e3ba992..0000000 --- a/test/+page.svelte +++ /dev/null @@ -1,20 +0,0 @@ - - - - -