mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-10-24 04:39:06 -05:00
feat: split the heavy site pages
A manufacturer page over 500 KB of Markdown becomes a summary: its largest consoles move to pages of their own, cut into parts when one console is still too large, and every console keeps its heading there. MAME's 1,564 cards move to four pages, its page keeping a row per entry with the card's old anchor. RetroDECK's arcade list gets its own page. site.js follows a moved card by content or by its row. The largest page drops from 10.5 MB to 0.88 MB. Emulator groups of the navigation open by initial (65 KB to 41 KB before the content). File cards are level 3 under a level 2, and the hook keeps the table of contents of card pages to level 2: platform pages no longer list every system id. Key/value cards name their columns. The sweep runs before the decoration, which kept every page no generator wrote any more.
This commit is contained in:
1 parent
33041b6bd1
commit
36ac7b0cd6
8 files changed
+1362
-729
No files matched your search
@@ -10,8 +10,28 @@ from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
# Pages made of file cards, level 3 headings by the hundred: their table of
|
||||
# contents stops at level 2, the consoles of a system page, the Files of an
|
||||
# emulator, the sections of a platform page (which listed every system id).
|
||||
CARD_PAGES = ("systems/", "emulators/", "platforms/")
|
||||
|
||||
|
||||
def on_page_markdown(markdown: str, page: Any, config: Any, files: Any) -> str: # noqa: ARG001
|
||||
"""Take lastmod from the page's own date, or leave it out."""
|
||||
page.update_date = str(page.meta.get("date_modified") or "")
|
||||
return markdown
|
||||
|
||||
|
||||
def _prune(items: list, depth: int) -> None:
|
||||
for item in items:
|
||||
if item.level >= depth:
|
||||
item.children = []
|
||||
else:
|
||||
_prune(item.children, depth)
|
||||
|
||||
|
||||
def on_page_content(html: str, page: Any, config: Any, files: Any) -> str: # noqa: ARG001
|
||||
"""Keep the table of contents of a page of cards to level 2."""
|
||||
if page.file.src_uri.startswith(CARD_PAGES):
|
||||
_prune(page.toc.items, 2)
|
||||
return html
|
||||
Reference in new issue
Block a user