Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i18n: Create Handlebars helper for dynamic navigation #281

Closed

Comments

@fhemberger
Copy link
Contributor

At the moment, the main and sidebar navigation are all hardwired to the templates. So if a translation team decides to have a different structure or to leave out pages (e.g. the blog section), there will be broken links.

We need to create a Handlebars helper to build (partial) navigation based on the page structure in site.json instead. This way templating would be easier to handle, e.g.

{{navigation}} – renders the main navigation
{{navigation 'about'}} – renders the sub navigation matching the given key

@fhemberger fhemberger changed the title i18n: Create Handlebars helper for dynamic naviagtion i18n: Create Handlebars helper for dynamic navigation Oct 24, 2015
@mrkiffie
Copy link
Contributor

mrkiffie commented Nov 6, 2015

I like this idea. It would make adding additional items to the navigation much simpler.

I've had a look at the structure of the site.json and it currently doesn't contain anything that we could use to determine the order of the menu items.

Maybe adding an order property to the items could be used to achieve the desired ordering of the links in the secondary nav.

      "docs": {
        "link": "docs",
        "text": "Docs",
        "es6": {
            "link": "docs/es6",
            "text": "ES6 in Node.js",
            "order": 1
        },
        "faq": {
            "link": "docs/faq",
            "text": "FAQ",
            "order": 2
        },
        "api": {
            "link": "/api/",
            "text": "API",
            "order": 3…

Or perhaps we could restructure the data for the secondary navigation into an array - something like this for example:

    "docs": {
        "link": "docs",
        "text": "Docs",
        "nav": [
            {"link": "docs/es6", "text": "ES6 in Node.js"},
            {"link": "docs/faq", "text": "FAQ"},
            {"link": "/api/", "text": "API"},
            {"link": "knowledge", "text": "Knowledge Base", "nav": […]}
        ]
    }

Either of these could provide what the data the Handlebars helper might need.

@fhemberger
Copy link
Contributor Author

The order of the menu items equals the order in the json. Please don't add more complexity than necessary. ;)

@mrkiffie
Copy link
Contributor

mrkiffie commented Nov 6, 2015

I've always considered the ordering of objects to be somewhat volatile. I might be lacking in my understanding of the way node handles JSON objects.

My understanding is more theoretical based and I haven't gone into much testing.

Does node reliable maintain the order of properties within JSON objects?

An object is an unordered collection of zero or more name/value pairs
- JSON RFC

@mrkiffie
Copy link
Contributor

The sidebar's menu's have started to grow in complexity and have deviated from a simple list managed by the site.json.

This can be seen by the recent addition of dynamic links to the version specific API and customised markup - see #324.

I'm not sure if or how to continue with #409. Any feedback on this would be appreciated.

@fhemberger
Copy link
Contributor Author

Closed by #409

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment