middleman-navtree
middleman-navtree copied to clipboard
Folders are not displayed at last level
I have the following tree:
fr:
beginner:
0-index.md: /fr/beginner/0-index.md
1-introduction.md: /fr/beginner/1-introduction.md
2-start-osm.md: /fr/beginner/2-start-osm.md
3-start-josm.md: /fr/beginner/3-start-josm.md
4-josm-plugins.md: /fr/beginner/4-josm-plugins.md
5-gps.md: /fr/beginner/5-gps.md
6-papers.md: /fr/beginner/6-papers.md
7-editing-with-josm.md: /fr/beginner/7-editing-with-josm.md
8-aerial-imagery-considerations.md: /fr/beginner/8-aerial-imagery-considerations.md
9-moving-forward.md: /fr/beginner/9-moving-forward.md
intermediate:
edit-in-detail-osm.md: /fr/intermediate/edit-in-detail-osm.md
With depth=1, the following code display nothing:
<%= tree_to_html(data.tree['fr'], 1) %>
But it should display:
Beginner
Intermediate
With depth=2, the result is good:
<%= tree_to_html(data.tree['fr'], 2) %>
Beginner
Guide du débutant
Introduction
Introduction à OpenStreetMap.org
Premiers pas avec JOSM
Préférences et greffons JOSM
Sur le terrain avec un GPS
Étude de terrain avec les Field Papers
Éditer avec JOSM
Utiliser l'imagerie aérienne
Pour aller plus loin
Intermediate
Edition avancée
Note: This is the tree corresponding to this guide (generate by jekyll): http://learnosm.org/fr/beginner/
What you are seeing is actually by design... I didn't want the depth argument to print non-clickable directories with nothing inside of them. The philosophy is that directories are for the nesting and grouping of pages, and they aren't worth printing if we aren't going to print the pages inside of them.
I could see how displaying folders might be useful if we supported directory indexes, but I can't think of a reason to display them under the current philosophy.
For the record, changing it would be fairly easy... the relevant code is in /lib/middleman-navtree/helpers.rb (in the tree_to_html() function definition). We would just need to move the depth conditional down below the part that prints an li containing dir_name: