bitovi / documentjs

The sophisticated documentation engine
https://documentjs.com/
MIT License
598 stars 381 forks source link

Generate nav links instead of hard coded in template #196

Open tomgreever opened 9 years ago

tomgreever commented 9 years ago

We should consider adding a feature that generates the links in the main nav, rather than being hard coded.

As I have been creating multiple themes for DocJS, I've noticed that it's a pain to switch themes on a project. It's not possible to just update my documentjs.json file with the new theme because my main nav links are hard coded. So then I update the layout.mustache and now I've modified the theme. That makes it more difficult to share themes across projects or update them.

Suggestion

Allow defining nav links in a markdown file, much like pages:

@nav Home index.html 1
@nav Components components.less.html 2

These would then be generated using a new template, like nav.mustache

<ul class="main-nav">
  {{#eachNavItem item}}
        <li class="{{#ifActive}} active{{/ifActive}}"><a href="{{url}}">{{title}}</a></li>
  {{/eachNavItem}}
 </ul>

nav.mustache is included in layout.mustache

tomgreever commented 9 years ago

Adding this would somewhat help with https://github.com/bitovi/documentjs/issues/178 because the main changes I'm looking for in my templates are updates to the hard-coded nav items.

tomgreever commented 9 years ago

For clarity, I'm referring to the top horizontal nav like this:

screen shot 2015-08-26 at 10 18 21 pm
justinbmeyer commented 9 years ago

@tomgreever I want to avoid this type of thing and encourage people to overwrite templates in "core html" generator. However, if we make theme's installable and sharable ... it can be very easy to create a theme that accepts these types of options from documentjs.json.

The reason is that if we go down the road of having people do customization in documentjs.json, we are likely to have to add a bunch of options there. People will want to pass a logo, color options, layouts, dimensions maybe. For DoneJS, I'd like to be able to put documentjs.json in package.json so keeping most theming out of siteConfig's would be helpful.

I'd like the core of documentjs to be about:

And the core of the html generator to be about:

I think we REALLY need a "bitovi" theme that can enable stuff like this.