1
0
mirror of https://github.com/squidfunk/mkdocs-material.git synced 2024-11-12 01:50:52 +01:00

Refactored and cleaned up partials

This commit is contained in:
squidfunk 2017-02-26 15:06:50 +01:00
parent eb6aedf5cc
commit d52f605200
8 changed files with 72 additions and 41 deletions

View File

@ -1,13 +1,25 @@
{% if nav_item.is_homepage %}
<li class="md-tabs__item">
<a href="{{ nav_item.url }}" title="{{ nav_item.title }}" class="md-tabs__link {% for nav_item_ in nav %} {% if nav_item_.url == page.url %} md-tabs__link--active {% endif %} {% endfor %}">
{% if not page.ancestors | length and nav | selectattr("url", page.url) %}
<a href="{{ nav_item.url }}" title="{{ nav_item.title }}" class="md-tabs__link md-tabs__link--active">
{{ nav_item.title }}
</a>
{% else %}
<a href="{{ nav_item.url }}" title="{{ nav_item.title }}" class="md-tabs__link">
{{ nav_item.title }}
</a>
{% endif %}
</li>
{% elif nav_item.children and nav_item.children | length > 0 %}
<li class="md-tabs__item">
<a href="{{ (nav_item.children | first).url }}" title="{{ nav_item.title }}" class="md-tabs__link {% if nav_item.active %} md-tabs__link--active {% endif %}">
{% if nav_item.active %}
<a href="{{ (nav_item.children | first).url }}" title="{{ nav_item.title }}" class="md-tabs__link md-tabs__link--active">
{{ nav_item.title }}
</a>
{% else %}
<a href="{{ (nav_item.children | first).url }}" title="{{ nav_item.title }}" class="md-tabs__link">
{{ nav_item.title }}
</a>
{% endif %}
</li>
{% endif %}

View File

@ -1,4 +1,8 @@
<nav class="md-tabs {% if page.ancestors | length > 0 %} md-tabs--active {% endif %}" data-md-component="tabs">
{% set class = "md-tabs" %}
{% if page.ancestors | length > 0 %}
{% set class = "md-tabs md-tabs--active" %}
{% endif %}
<nav class="{{ class }}" data-md-component="tabs">
<div class="md-tabs__inner md-grid">
<ul class="md-tabs__list">
{% for nav_item in nav %}

View File

@ -22,6 +22,8 @@
<!-- Main navigation -->
<nav class="md-nav md-nav--primary" data-md-level="0">
<!-- Site title -->
<label class="md-nav__title md-nav__title--site" for="drawer">
{% if config.extra.logo %}
<i class="md-logo md-nav__button">
@ -32,11 +34,15 @@
{% endif %}
{{ config.site_name }}
</label>
<!-- Repository containing source -->
{% if config.repo_url %}
<div class="md-nav__source">
{% include "partials/source.html" %}
</div>
{% endif %}
<!-- Render item list -->
<ul class="md-nav__list" data-md-scrollfix>
{% for nav_item in nav %}
{% set path = "nav-" + loop.index | string %}

View File

@ -23,26 +23,33 @@
<!-- Home page -->
{% if nav_item.is_homepage %}
<li class="md-tabs__item">
{% if not page.ancestors | length and nav | selectattr("url", page.url) %}
<a href="{{ nav_item.url }}" title="{{ nav_item.title }}"
class="md-tabs__link
{% for nav_item_ in nav %}
{% if nav_item_.url == page.url %}
md-tabs__link--active
{% endif %}
{% endfor %}">
class="md-tabs__link md-tabs__link--active">
{{ nav_item.title }}
</a>
{% else %}
<a href="{{ nav_item.url }}" title="{{ nav_item.title }}"
class="md-tabs__link">
{{ nav_item.title }}
</a>
{% endif %}
</li>
<!-- Main navigation item with nested items -->
{% elif nav_item.children and nav_item.children | length > 0 %}
<li class="md-tabs__item">
<a href="{{ (nav_item.children | first).url }}"
title="{{ nav_item.title }}" class="md-tabs__link
{% if nav_item.active %}
md-tabs__link--active
{% endif %}">
<a href="{{ (nav_item.children | first).url }}"
title="{{ nav_item.title }}"
class="md-tabs__link md-tabs__link--active">
{{ nav_item.title }}
</a>
{% else %}
<a href="{{ (nav_item.children | first).url }}"
title="{{ nav_item.title }}" class="md-tabs__link">
{{ nav_item.title }}
</a>
{% endif %}
</li>
{% endif %}

View File

@ -20,12 +20,14 @@
IN THE SOFTWARE.
-->
<!-- Tabs with outline (level denotes the active level) -->
<nav class="md-tabs
{% if page.ancestors | length > 0 %}
md-tabs--active
{% endif %}"
data-md-component="tabs">
<!-- Determine class according to level -->
{% set class = "md-tabs" %}
{% if page.ancestors | length > 0 %}
{% set class = "md-tabs md-tabs--active" %}
{% endif %}
<!-- Tabs with outline -->
<nav class="{{ class }}" data-md-component="tabs">
<div class="md-tabs__inner md-grid">
<ul class="md-tabs__list">
{% for nav_item in nav %}