eleventy
eleventy copied to clipboard
How to not expand variables fully with njk
I want to replicate the header from my site in eleventy: https://nikitavoloboev.xyz It looks like:
In my navigation.njk I have this line {{ nav.data.navtitle }}
This expands over all the templates I have that have navtitle property. But I want to mix in some links that are just links. i.e. wiki in example above links externally. Then after, I have Likes and that is internal to Eleventy again.
I am not sure what is the clean way to solve this issue.
Full code for the url is actually
<div class="nav__content">
<ul class="nav__menu js-nav-menu" id="nav-menu">
{%- for nav in collections.nav -%} {%- set isCurrent = (nav.url ==
page.url) -%} {%- set isParent = nav.url != '/' and page.url and nav.url
in page.url -%}
<li
class="nav__item{% if isCurrent or isParent %} nav__item--active{% endif %}"
>
<a
href="{% if isCurrent %}#main{% else %}{{ nav.url | url }}{% endif %}"
class="nav__link"
{%
if
isCurrent
%}aria-current="page"
{%
endif
%}
>
{{ nav.data.navtitle }}
</a>
</li>
{%- endfor -%}
</ul>
</div>
So I do want to keep the set isCurrent logic to indicate which tab is active:
But still adding a link inbetween the nav entries
Unfortunately this issue slipped under the radar—I’m finally circling back through some of the really old issues on the tracker and am unfortunately declaring issue bankruptcy on these—sorry! If you feel like this issue is still relevant, feel free to reopen a new issue with the same exact content! Appreciate your understanding!