Skip to content
Snippets Groups Projects
menu_single.html 1.06 KiB
Newer Older
  • Learn to ignore specific revisions
  • Tom Wiesing's avatar
    Tom Wiesing committed
    {% comment %}
      This page creates a single (non-submenu) item. It expects `item` as a variable. 
    {% endcomment %}
    
    
    Tom Wiesing's avatar
    Tom Wiesing committed
    {% assign menu_active = false %}
    
    {% assign base_folder = page.url | split: '/' %}
    {% assign base_folder = base_folder[1] %}
    
    
    Tom Wiesing's avatar
    Tom Wiesing committed
    {% assign represents = include.item.active | split: '/' %}
    
    Tom Wiesing's avatar
    Tom Wiesing committed
    {% assign represents = represents[1] %}
    
    {% if represents %}
        {% if base_folder == represents %}
            {% assign menu_active = true %}
        {% endif %}
    {% endif %}
    
    
    Tom Wiesing's avatar
    Tom Wiesing committed
    {% if page.url == include.item.url %}
    
    Tom Wiesing's avatar
    Tom Wiesing committed
        {% assign menu_active = true %}
    {% endif %}
    
    
    Tom Wiesing's avatar
    Tom Wiesing committed
    {% unless include.item.menu_hidden %}
    
    Tom Wiesing's avatar
    Tom Wiesing committed
      <li
    
    Tom Wiesing's avatar
    Tom Wiesing committed
        {% if menu_active %}class="active"{% endif %}
    
    Tom Wiesing's avatar
    Tom Wiesing committed
        {% if page.url == include.item.url %}class="active"{% endif %}
    
    Tom Wiesing's avatar
    Tom Wiesing committed
      >
    
    Tom Wiesing's avatar
    Tom Wiesing committed
        {% if include.item.external %}
            <a href="{{ include.item.url }}" target="_blank">
    
    Tom Wiesing's avatar
    Tom Wiesing committed
        {% else %}
    
    Tom Wiesing's avatar
    Tom Wiesing committed
            <a href="{{ site.baseurl }}{{ include.item.url }}">
    
    Tom Wiesing's avatar
    Tom Wiesing committed
        {% endif %}
        
    
    Tom Wiesing's avatar
    Tom Wiesing committed
          {% if include.item.menu_title %}
            {{ include.item.menu_title }}
    
    Tom Wiesing's avatar
    Tom Wiesing committed
          {% else %}
    
    Tom Wiesing's avatar
    Tom Wiesing committed
            {{ include.item.title }}
    
    Tom Wiesing's avatar
    Tom Wiesing committed
          {% endif %}
        </a>
      </li>
    {% endunless %}