mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-10-27 14:17:25 -05:00
Status badges and hash-listing blocks leave the search index, card titles weigh as page titles, and Pagefind ranking is set inside a range where the ten gate queries all answer (search_gate.py: 10/10). Tables are set up and measured when they near the screen, which relaid out a 3,800-row page after its first paint, and console icons hold their box.
24 lines
1.1 KiB
JavaScript
24 lines
1.1 KiB
JavaScript
// Raw Pagefind results with their scores, to see why a page ranks where it does.
|
|
// node search_scores.mjs <base url> <query> [ranking json]
|
|
import { chromium } from 'playwright-core';
|
|
|
|
const [base, query, ranking] = process.argv.slice(2);
|
|
const browser = await chromium.launch({ executablePath: '/usr/bin/google-chrome' });
|
|
const page = await browser.newPage();
|
|
await page.goto(base, { waitUntil: 'networkidle' });
|
|
const rows = await page.evaluate(async ({ root, query, ranking }) => {
|
|
const pagefind = await import(`${root}pagefind/pagefind.js`);
|
|
if (ranking) await pagefind.options({ ranking: JSON.parse(ranking) });
|
|
const search = await pagefind.search(query);
|
|
const top = search.results.slice(0, 8);
|
|
const data = await Promise.all(top.map((result) => result.data()));
|
|
return top.map((result, index) => ({
|
|
score: result.score.toFixed(3),
|
|
url: data[index].url,
|
|
words: data[index].word_count,
|
|
hits: result.words.length,
|
|
}));
|
|
}, { root: base, query, ranking });
|
|
for (const row of rows) console.log(row.score, row.words, row.hits, row.url);
|
|
await browser.close();
|