diff options
| author | alex <alex@pdp7.net> | 2026-09-18 16:42:29 +0200 |
|---|---|---|
| committer | alex <alex@pdp7.net> | 2026-09-18 16:42:29 +0200 |
| commit | c939bc7657c4a5cbaad9ee9be6f1f86d2f3f1dd9 (patch) | |
| tree | e7a73e66bb0acc47f5087c819ed5cd3010d9c8cc | |
| parent | ad7087f8be70ede67e357c5ca98980957d189b54 (diff) | |
Add navigation to parent
| -rwxr-xr-x | blog/footers.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/blog/footers.py b/blog/footers.py index 4ec7f50d..49932f1d 100755 --- a/blog/footers.py +++ b/blog/footers.py @@ -17,6 +17,11 @@ EDIT_IN_GITHUB = { "en": "Edit this page.", } +PARENT = { + "es": "Subir.", + "en": "Go to parent." +} + ENGLISH_PAGES = ('about.gmi', 'gemini.gmi',) content_gmi_files = [str(p.relative_to(content)) for p in pathlib.Path(content).glob("**/*.gmi")] @@ -43,6 +48,15 @@ for gmi in pathlib.Path.cwd().glob("**/*.gmi"): if content_source: footer.append(f"=> https://github.com/alexpdp7/alexpdp7/edit/master/{content_source} {EDIT_IN_GITHUB[language]}") + closest_index = gmi.with_name("index.gmi") + while closest_index == gmi or closest_index.is_relative_to(pathlib.Path.cwd()) and not closest_index.exists(): + closest_index = closest_index.parent.parent / "index.gmi" + + closest_index = closest_index if closest_index.exists() else None + if closest_index: + index_link = "/".join([".."] * (len(gmi.parts) - len(closest_index.parts))) + "/" + footer.append(f"=> {index_link} {PARENT[language]}") + gmi_content = gmi.read_text() assert gmi_content.endswith("\n"), f"{gmi} has no trailing new line" assert not gmi_content.endswith("\n\n"), f"{gmi} has extra empty blank line" |
