fralau / mkdocs-macros-plugin

Create richer and more beautiful pages in MkDocs, by using variables and calls to macros in the markdown code.
https://mkdocs-macros-plugin.readthedocs.io
Other
318 stars 50 forks source link

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

Closed niklasfink closed 1 year ago

niklasfink commented 1 year ago

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[bot] commented 1 year ago

Welcome to this project and thank you!' first issue

fralau commented 1 year ago

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 commented 1 year ago

@niklasfink Is it still an issue?

niklasfink commented 1 year ago

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 commented 1 year ago

Some ideas:

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