This discussion has been helpful, as I’m trying to do something similar. However, I’ve got a few constraints.
- I cannot predict how deep the navigation will need to be.
- It needs to be generated automatically (I cannot use a hierarchy defined in a .yml file, like this one)
- I don’t think I can use the traversal methods, because I can’t guarantee each folder will contain an “index.html” for defining parent/child relationships (I played around with them a lot before I realized this).
Basically, I’d like to reproduce something similar to the one at __middleman/sitemap
, but in a page template or partial.
Some possible leads are
- This
all_files_under(*paths)
utility method
- Reusing the code used to build the sitemap metapage on my own pages (the template for it is here and I also found the
sitemap_tree.render
method).
- Writing a script from scratch that looks at each resource and pieces them together into a tree based on their file paths.
Is there any reason I can’t reuse the same methods used on the metapages in my own templates? If so, and thoughts on how could I adapt them to work for me?