Lego2012
10/24/2016 - 4:15 PM

Die Variable "location"

Die Variable "location"

<!-- Capture and store a URL -->
<!-- Der Teil zwischen den Slashes wird isoliert -->
{% capture location %}{{ page.url | split:'/' }}{% endcapture %}
<header class="main-header" role="banner">
  <div class="grid">
    <div class="grid__col-12">
      <a class="site-logo" href="/" title="Webconfs.me - Home">
        WebConfs
      </a>
      <nav class="navbar" role="navigation">
        <ul class="nav">
          {% for page in site.pages  %}
            <!-- Compare the page title to the URL -->
            {% assign current = page.title | downcase %}
            {% if page.title %}
            <li {% if location == current %} class="nav__item--current" {% else %} class="nav__item" {% endif %}>
              <a href="{{ page.url | prepend: site.baseurl }}">{{ page.title }}</a>
            </li>
            {% endif %}
          {% endfor %}
        </ul>
      </nav>
    </div>
  </div>
</header>