Repository navigation
Replies: 1 comment
|
For this, I would use an In hooks:
- page_list.pyIn from pathlib import PurePosixPath
def on_page_markdown(markdown, *, page, files, **kwargs):
current = PurePosixPath(page.file.src_uri)
if current.name != "index.md":
return markdown
siblings = sorted(
PurePosixPath(file.src_uri)
for file in files.documentation_pages()
if PurePosixPath(file.src_uri).parent == current.parent
and file.src_uri != page.file.src_uri
)
if not siblings:
return markdown
links = [f"- [{path.stem}]({path.name})" for path in siblings]
return markdown + "\n\n## Pages\n\n" + "\n".join(links) + "\n"This lists the other documentation pages directly alongside each I tested your directory structure with MkDocs 1.6.1 using both built-in themes: |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
I would like to have a page be automatically populated with a list of pages based on the current index page.
As an example, assume the following structure in
docs/:I now would like to add a way to have
subpage/index.mdlistabout.mdandcredits.mdin its page content (And also link to them), but I'm unsure wether a hook or a page template (using theme extension) would be better.I've created a page list like that in the past using a theme extension, but I wonder if a Hook would be overall better here...
All reactions