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

Ordering breaks when rest pattern is used in mkdocs > nav #86

Open
ketrab2004 opened this issue Sep 17, 2023 · 7 comments
Open

Ordering breaks when rest pattern is used in mkdocs > nav #86

ketrab2004 opened this issue Sep 17, 2023 · 7 comments

Comments

@ketrab2004
Copy link

I work on a small project so I only want a single .pages file to control the entire structure of the site.
But that isn't really possible with this issue, when you use folders.

Example file structure:

* index.md
* extras.md
* documentation/
    * main.md
    * systems/
        * index.md
        * coolSystem.md
    * plugins.md

.pages

nav:
    - Home: index.md
    - Documentation:
        - Main: documentation/main
        - Systems:
            - ... | documentation/*
        - Plugins: documentation/plugins
    - Extras: extras.md

Here the Documentation>Systems sidebar item has nothing under it. Clicking on it just links to the root.
When I change the pattern to be regex it also doesn't work.

@lukasgeiter
Copy link
Owner

The ... in a .pages file only targets the remaining items in the directory of the .pages file. Try putting the nav block into mkdocs.yml instead.

@ketrab2004
Copy link
Author

ketrab2004 commented Sep 18, 2023

For me ... shows everything, also in subdirectories. And adding a filter like *r* correctly finds everything that has an r in it, also in subdirectories. (but only in the file name itself, not in directories' names)

But putting the nav into mkdocs.yml works great (after adding .md), except now it doesn't order correctly under Documentation for some reason. But it does work correctly for outside of Documentation.

nav:
    - Home: index.md
    - Documentation:
        - Main: documentation/main.md
        - Systems:
            - ... | documentation/*
        - Plugins: documentation/plugins.md
    - Extras: extras.md

resulting sidebar

* Home
* Documentation
    * Plugins
    * Main
    * Systems
* Extras

@lukasgeiter
Copy link
Owner

documentation/* doesn't match any files, you would need something like documentation/**. But that's probably also not what you want so you would have to make it ... | flat | documentation/**.

This would be a lot easier if you would use two .pages files. Your navigation structure matches the file structure 1:1 so you only have to tweak the order of the items in the root and under documentation.

@ketrab2004
Copy link
Author

For me /*, /** and /**/* all work and match the same files.

Also my example nav isn't completely accurate, it is more something like this:

nav:
    - Home: index.md
    - Documentation:
        - Main: documentation/main.md
        - Systems:
            - ... | documentation/systems/*
        - Plugins: documentation/plugins.md
    - ... | other/*
    - Extras: extras.md

But now that I have added the ... | other/* the ordering of everything, not only under Documentation, does not match the nav. I can't really tell on what the order is based.

I haven't yet tried using multiple .pages files, but I don't think that should affect the ordering.

Since the issue topic has moved from rest filter patterns (though I don't really know why it didn't work within the .pages but does in mkdocs.yml) to ordering should I rename the issue?

@lukasgeiter
Copy link
Owner

Sure documentation/systems/* works, but before you wrote documentation/*.

The ordering being off likely means that the plugin is not doing anything at all for some reason. But feel free to rename the issue - I don't really mind.

Without all the information it's hard to diagnose what's happening. Could you send me a full example to reproduce your problem?

@ketrab2004
Copy link
Author

ketrab2004 commented Sep 20, 2023

Here is a reproduction example: https://github.com/ketrab2004/awesome-pages-issue-repro

It does use the section/page name and the rest filter pattern correctly, only the ordering is incorrect.

@lukasgeiter
Copy link
Owner

Thanks for the example! There is a strange interaction between defining the navigation in mkdocs.yml and using the order option. Once again, I really recommend using separate files.

  1. Remove nav and filename: none from mkdocs.yml
  2. Add .pages in the docs` folder:
nav:
    - index.md
    - documentation
    - other.md
    - extras
  1. Add .pages in the documentation folder:
nav:
    - Main: main.md
    - systems
    - Plugins: plugins.md

@ketrab2004 ketrab2004 changed the title Rest Filter Patterns don't work with directories Ordering breaks when rest pattern is used in mkdocs > nav Sep 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants