Hi!
I’m trying to make a complicated blog, where I want to merge multiple WP blogs onto Ghost, since I can finally have an easier platform to write on.
On of these things I need to do, includes the navigation menu.
I’d like to only show certain navigation items, depending on what page/slug/post you’re on. I’m using content collections and have a nice setup in my routes.yaml file. It would be awesome to do this based on the whole content collection.
Let’s say I’m reading pages and posts in my English collection, I’d like to show the pages in the navigation menu (primary menu) that are in English. When I’m reading my Swedish collection, I’d like to show the Swedish pages etc.
The simplest way to do this is to check either for a tag on the post indicating language (like #es) or checking the context of the route (#is “route”).
Then, you can conditionally chain together your nav based on language (you sacrifice the ability to update the items from Ghost Admin).
{{#has tag="#es"}}
... Spanish nav items
{{else has tag="#en"}}
... English nav items
{{/has}}
You should be able to do {{#is 'sv'}}. This will work when you’re on the custom route. To better understand these values, you can log the current context by putting {{log this}} at the top level of your default.hbs` file.