mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-15 14:33:47 -06:00
fix: record list parts by their front matter
This commit is contained in:
1 parent
3a36350f5c
commit
1e96968744
4 files changed
+272
-8
No files matched your search
@@ -3357,6 +3357,8 @@ def _published_parts() -> dict[str, str]:
|
||||
def _parent_page(link: str) -> str:
|
||||
"""The page a `parent:` link names (/platforms/batocera/), under docs/."""
|
||||
path, _, fragment = link.partition("#")
|
||||
# Written with the site's base (/retrobios/emulators/x/) or without it.
|
||||
path = path.removeprefix(sitestarlight.BASE.rstrip("/"))
|
||||
stem = path.strip("/") or "index"
|
||||
return f"{stem}.md" + (f"#{fragment}" if fragment else "")
|
||||
|
||||
@@ -3374,13 +3376,11 @@ def record_parts(docs: Path, present: set[str], published: dict[str, str]) -> di
|
||||
if not page.is_file():
|
||||
page = page.with_suffix(".mdx")
|
||||
try:
|
||||
with page.open(encoding="utf-8") as handle:
|
||||
head = handle.read(2048)
|
||||
parent = _front_matter(page.read_text(encoding="utf-8")).get("parent")
|
||||
except OSError:
|
||||
continue
|
||||
link = re.search(r"^parent:\n(?: .*\n)*? link: (\"[^\"\n]*\")", head, re.M)
|
||||
if link and rel not in found:
|
||||
found[rel] = _parent_page(json.loads(link[1]))
|
||||
if isinstance(parent, dict) and parent.get("link") and rel not in found:
|
||||
found[rel] = _parent_page(str(parent["link"]))
|
||||
return dict(sorted(found.items()))
|
||||
|
||||
|
||||
|
||||
@@ -819,12 +819,13 @@ def redirects(profiles: dict, present: set[str],
|
||||
that is already a page's address, is left out. Addresses are written
|
||||
under the site root, without its base. ``moved`` adds pages that moved
|
||||
by generation, old page to new page, the new one with an optional
|
||||
#fragment."""
|
||||
#fragment. A page MOVED_PAGES names keeps that target over the part
|
||||
record: cross-reference-minui is answered on MinUI's own page."""
|
||||
def address(rel: str) -> str:
|
||||
page, _, fragment = rel.partition("#")
|
||||
return "/" + page_url(page)[len(BASE):] + (f"#{fragment}" if fragment else "")
|
||||
|
||||
out = {address(old): address(new) for old, new in {**MOVED_PAGES, **(moved or {})}.items()
|
||||
out = {address(old): address(new) for old, new in {**(moved or {}), **MOVED_PAGES}.items()
|
||||
if old not in present and new.partition("#")[0] in present}
|
||||
pages = {rel.casefold() for rel in present}
|
||||
claims: dict[str, set[str]] = {}
|
||||
|
||||
Reference in new issue
Block a user