Generate a _Sidebar page so the wiki shows its subpages
TirSystem/github-action: Publish wiki / publish-wiki (push) Skipped
TirSystem/github-action: Sync GitHub mirror metadata / sync-metadata (push) Skipped
Validate workflows / validate (pull_request) Successful in 15s
TirSystem/github-action: Publish wiki / publish-wiki (push) Skipped
TirSystem/github-action: Sync GitHub mirror metadata / sync-metadata (push) Skipped
Validate workflows / validate (pull_request) Successful in 15s
Task: MIL-005#3
This commit is contained in:
+34
-2
@@ -184,9 +184,41 @@ def render_page(page: Page, repo_root: Path = REPO_ROOT) -> str:
|
||||
return banner + body + "\n"
|
||||
|
||||
|
||||
# Link text of the sidebar: English, then one list per translation code.
|
||||
SIDEBAR_TITLE = "TirSystem GitHub Actions"
|
||||
SIDEBAR_LABELS: dict[str, tuple[str, ...]] = {
|
||||
"en": ("Home", "Onboarding", "Credentials", "Troubleshooting", "Quality checks", "Upgrading", "Capabilities"),
|
||||
"da": ("Hjem", "Tilslutning", "Credentials", "Fejlfinding", "Kvalitetskontrol", "Opgradering", "Kapabiliteter"),
|
||||
"ms": ("Utama", "Menyertakan", "Kelayakan", "Diagnosis", "Semakan kualiti", "Menaik taraf", "Keupayaan"),
|
||||
}
|
||||
SIDEBAR_NAME = "_Sidebar.md"
|
||||
|
||||
|
||||
def render_sidebar() -> str:
|
||||
"""Return the navigation shown beside every wiki page.
|
||||
|
||||
Gitea lists subpages only through a ``_Sidebar`` page, so without it a
|
||||
visitor sees the home page and no way to the others.
|
||||
"""
|
||||
languages = (("en", "English", ""), *((code, label, f".{code}") for code, label in LANGUAGES))
|
||||
lines = [
|
||||
f"<!-- Generated by {GENERATOR}. Edit the generator, not this page. -->",
|
||||
"",
|
||||
f"**{SIDEBAR_TITLE}**",
|
||||
]
|
||||
for code, label, suffix in languages:
|
||||
labels = SIDEBAR_LABELS[code]
|
||||
assert len(labels) == len(PAGES), "one sidebar label per page"
|
||||
lines += ["", f"**{label}**", ""]
|
||||
lines += [f"- [{text}]({page.name}{suffix})" for text, page in zip(labels, PAGES)]
|
||||
return chr(10).join(lines) + chr(10)
|
||||
|
||||
|
||||
def build_all(repo_root: Path = REPO_ROOT) -> dict[str, str]:
|
||||
"""Return ``{file name: content}`` for every English page."""
|
||||
return {f"{page.name}.md": render_page(page, repo_root) for page in PAGES}
|
||||
"""Return ``{file name: content}`` for every English page and the sidebar."""
|
||||
pages = {f"{page.name}.md": render_page(page, repo_root) for page in PAGES}
|
||||
pages[SIDEBAR_NAME] = render_sidebar()
|
||||
return pages
|
||||
|
||||
|
||||
def write_pages(wiki_dir: Path = WIKI_DIR, repo_root: Path = REPO_ROOT) -> list[str]:
|
||||
|
||||
Reference in New Issue
Block a user