-
Notifications
You must be signed in to change notification settings - Fork 20
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
AV-75840 top nav highlight #178
Conversation
This is more complicated than it looks, partly because the Nav data-structure is a bit odd (e.g. the Home icon isn't generated from the Home configuration for... reasons?) This involves grubbing around in the site keys, and is therefore dependent on magic globals that are created while running templating code... (e.g. it works, but will require some documentation or rework, as will be fun to debug in future)
I don't see any of the duplication behaviours on the preview site that you've provided anymore, and the spacing looks to be what I'd expect. I can 👍 this if we want to get it merged, or we can wait for further comments. |
@@ -9,7 +9,8 @@ | |||
</a> | |||
</li> | |||
<li> | |||
<a class="navbar-brand cb-documentation" href="{{#with (and site.url site.homeUrl)}}{{{@root.site.url}}}{{{this}}}{{else}}{{{siteRootPath}}}{{/with}}"> | |||
<a class="navbar-brand cb-documentation" | |||
href="{{#if (and site.url site.homeUrl)}}{{{site.url}}}{{{site.homeUrl}}}{{else}}{{{siteRootPath}}}{{/if}}"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious if this still works as expected with replacing the #with helper?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes! So with
is basically an if
but with scoping.
So {{{@root.site.url}}}{{{this}}}
relied on that behaviour + and
's behaviour (or returning the second truthy value on success) which honestly is a bit "cute" to understand.
This refactor just makes the logic a bit more explicit.
Deployed the contribute/style-guide nav changes to Staging and looks like this logic does NOT work for that: Is this a blocker? (e.g. getting to the writer's guide is something you generally don't do by accident, so not sure if this needs to delay pushing it out?) |
What would we even expect to highlight in the top nav for this? The home icon? I honestly think it's negligible and not a blocker. We care more about the actual product highlighting, not highlights for something that's largely supposed to be internal. |
Thanks @sarahlwelton, that makes sense. (Is a little odd that the old Writer's Guide content, under /home/contribute doesn't trigger it, but would arguably be weirder if only that one section did) |
This PR adds a highlight to the top nav for which section we're in:
You can currently see it in action on Staging:
The logic used is:
components
key, then it's highlightedhome
component...So we ALSO need to check if the
url
matches the pagehome
component has to have special handling, where we check if it (and ONLY it) could be highlighted