- Add the page in the UI directory with the markup and the code behind file.
- Add a new route to render the layout with the new page.
To create navigation between the pages I used the flow-router-helpers package. After installing it, I exposed the routes to the view model of the main layout:
Template.mainLayout.helpers({ navItems() { return FlowRouter._routes; } });
Not sure if the '_routes' property is meant to be public but I did not found an alternative without the underscore prefix. Anyway, next consume the routes from the markup:
{{#each navItems}} <li class="{{isActiveRoute name}}"> <a href="{{pathFor name}}">{{options.displayName}}</a> </li> {{/each}}
Things to note are the 'pathFor' and 'isActiveRoute' helper methods, they are all included in the helpers package and quite useful to build the links in the UI.
Yay! We have another page with nice top level navigation menu, that wasn't too hard. You can follow the code along by using this repo tag or visit the live demo.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.