fix: rank a console first for its own name

The PlayStation 2 page holds every word of "playstation bios" and pagefind ignores the words a page has that the query lacks, so its own body matches put it first. A console whose every word another system page's consoles also hold is now written again in an `exact` field (weight 20). File names reach the `files` field as their parts: whole names let "ds" reach twelve dsi_* names on the DSi page. `consoles` weighs 100 so an emulator named after its console (Saturn.emu) comes second, and `aliases` 10 so the Nintendo page keeps "gba bios". The gate runs both directions of the PlayStation, Game Boy, DS and Wii pairs and Saturn.
This commit is contained in:
Abdessamad Derraz committed 2026-10-27 06:54:08 +01:00
1 parent 6a611cd77a
commit 07f785cfd7
9 files changed
+191 -25

No files matched your search

+9
View File
@@ -3065,6 +3065,14 @@ def decorate_markdown_pages(docs: Path) -> dict[str, str]:
"""
lastmod: dict[str, str] = {}
terms = sitestarlight.glossary_terms(_REPO_ROOT / WIKI_SRC_DIR / "glossary.md")
# The console words of every system page, decorated or not: a console
# another page's words cover gets a search field of its own.
console_words: dict[str, set[str]] = {}
for path in sorted((docs / "systems").glob("*.md*")):
text = path.read_text(encoding="utf-8")
words = sitestarlight.page_console_words(_front_matter(text), text)
if words:
console_words[path.relative_to(docs).with_suffix("").as_posix()] = words
for path in sorted(docs.rglob("*.md")):
relative = path.relative_to(docs)
if any(part in LOCAL_NOTE_DIRS for part in relative.parts[:-1]):
@@ -3125,6 +3133,7 @@ def decorate_markdown_pages(docs: Path) -> dict[str, str]:
logo=str(authored.get("logo") or ""),
parent=authored.get("parent"),
authored=authored,
words_by_page=console_words,
)
write_decorated(docs / target, text)
# One file per page: a page that gained or lost its components