Templates NEW Links


How it works

/anyblades/blades/refs/heads/main/_includes/blades/links.njk :


Usage example for /docs/plugins/navigation/#bring-your-own-html-render-the-menu-items-manually:

{% assign links = collections.all | eleventyNavigation %}
{% render blades/links, links: links, current_url: page.url %}

How it works

/anyblades/blades/refs/heads/main/_includes/blades/links.liquid :

<ul>
  {%- for link in links %}
    <li>
      {% # prettier-ignore %}
      <a href="{{ link.url }}" {% if link.url == current_url %}aria-current="page"{% endif %}>
        {{- link.title -}}
      </a>
    </li>
  {%- endfor %}
</ul>
{% # prettier-ignore %}
{% comment %}```

Pass the links and the current URL explicitly so nothing else leaks into scope:

{% include 'blades/links.twig' with { links: menu, current_url: app.request.pathInfo } only %}

How it works

/anyblades/blades/refs/heads/main/_includes/blades/links.twig :

<ul>
  {%- for link in links %}
    <li>
      <a href="{{ link.url }}" {% if link.url == current_url %}aria-current="page"{% endif %}>
        {{- link.title -}}
      </a>
    </li>
  {%- endfor %}
</ul>