Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'navigation' Object not containing enough page information. #156

Closed
niklasfink opened this issue Mar 21, 2023 · 5 comments
Closed

'navigation' Object not containing enough page information. #156

niklasfink opened this issue Mar 21, 2023 · 5 comments
Labels
external Concerns another part of the ecosystem info required Further information is requested stale No news, closing

Comments

@niklasfink
Copy link

Hi, I wanted to use the navigation (or files) object to get page information of sub pages.

With this, I want to build a rich overview page of all sub-pages including some of their meta data. The function would be similar to the Excerpt Macro in Confluence.

Another example (to try to explain the goal of this) would be building an index of all sub-pages within a specific folder. For this, you need the Title of the page and the URL and can the build a link. However, at the moment, I don't see how this should work.

Issue

The pages (List[Page]) within the navigation object neither contain the Title of a page, nor any meta data in most cases. It seems like they only contain this information the further down in the directory tree they are.

Jinja Template Example

{% for page in navigation.pages if page.parent.title == "Folder1" %}
    Title: {{ page.title }} // URL: {{ page.url }} // Meta: {{page.meta.metavar|default('None')}}
{% endfor %}

Pictures

In the following picture, we only get the details of File0 (the current page) and the other pages don't show any detail infos, except the URL.
image

In the next picture, we have it working as expected. The details of all sub-pages of Folder1 are retrieved.
image

What's the issue here or how can this be done differently? From my perspective, navigation.pages should have the same content, independent to where it is used in the file tree.

@github-actions
Copy link

Welcome to this project and thank you!' first issue

@fralau
Copy link
Owner

fralau commented Apr 22, 2023

Hello, I believe you could do that. But this would be more a mkdocs issue wouldn't it?

https://www.mkdocs.org/dev-guide/themes/#config

@fralau fralau added the external Concerns another part of the ecosystem label Apr 22, 2023
@fralau fralau added the info required Further information is requested label Apr 30, 2023
@fralau fralau added the stale No news, closing label Jul 3, 2023
@fralau
Copy link
Owner

fralau commented Jul 12, 2023

@niklasfink Is it still an issue?

@niklasfink
Copy link
Author

I don’t think this is generally solved, but I also don’t know whose responsibility it would be to implement this.
I worked around it by modifying the rendering queue.

@fralau
Copy link
Owner

fralau commented Jul 12, 2023

Some ideas:

  • Keep into account that the navigation is being built while mkdocs is rendering the pages, unless you defined your page structure in the config file (mkdocs.yaml). So when you are rendering the first page, the second and third have not been read yet.
  • Confluence's macros are rendered at runtime, after the navigation has been calculated.
  • So if you want to make an equivalent of the Excerpt macro, either you work with a complete navigation when the page is being rendered, or... you need a second pass. Which might not be easy to implement, on a static website.

It seems to me that the question should be asked to the mkdocs team?

@fralau fralau closed this as completed Jul 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
external Concerns another part of the ecosystem info required Further information is requested stale No news, closing
Projects
None yet
Development

No branches or pull requests

2 participants