bryanbraun / middleman-navtree

For building navigation trees & menus in Middleman.
MIT License
45 stars 17 forks source link

How to maintain a custom nav structure #1

Closed oskarrough closed 9 years ago

oskarrough commented 10 years ago

middleman-navtree automatically (over)writes a tree.yml reflecting the structure in /source which is great. What is the recommened way of maintaining a custom structure? Say a different ordering if you're files aren't prefixed with a number.

Copy/paste the tree.yml, duplicate it and modify it and reference it in config.rb in the navtree settings?

And thanks for the great plugin!

oskarrough commented 10 years ago

Or say with a structure like so:

screen shot 2014-08-10 at 18 54 16

How would you remove the prefixes "1-" etc.?

bryanbraun commented 10 years ago

@oskarrough, that's an interesting idea. This is an issue that's been floating in the back of my mind for a while.

The number prefixing should work fine for ordering... so is the issue is that you just want cleaner directory names in the nav?

If so, then maybe instead of pasting all of tree.yml into the settings, what if we just added a setting that accepted a key-value hash of specific directory name overrides? Something like this:

options.dir_name_overrides = { "1-Preface" => "Preface", "2-Front-end" => "Front-end"}

We shouldn't need filename overrides because discover_title should take care of that.

I'd have to figure out how to work that logic on the backend, but does that address the issue?

assimovt commented 9 years ago

Got the same problem. The idea of overriding directory names sounds good, so :+1: for it.

bryanbraun commented 9 years ago

@assimovt submitted a pull request that included an option to manually manage the tree.yml file. It's described here in detail.

In short, you get an option to prevent further updates to tree.yml, once the file has been generated. That way you can manually edit it to use whatever Titles and URLs you want. To enable the option, you would include this line with your navtree settings in config.rb:

options.automatic_tree_updates = false

I liked the approach, so after a bit of discussion I went ahead and integrated it. The README.md has been updated to include this new option and I've pushed it up to rubygems as part of the middleman-navtree 0.1.9 version.

I'm considering this issue closed. Thanks for the great discussion and resolution!