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

@ -35,11 +35,11 @@
{% endblock %}
</div>
<div class="md-flex__cell md-flex__cell--shrink">
<div class="md-header-nav__source">
{% if config.repo_url %}
{% include "partials/source.html" %}
{% endif %}
</div>
<div class="md-header-nav__source">
{% if config.repo_url %}
{% include "partials/source.html" %}
{% endif %}
</div>
</div>
</div>
</nav>

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 %}">
{{ nav_item.title }}
</a>
{% 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 %}">
{{ nav_item.title }}
</a>
{% 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

@ -57,7 +57,7 @@
<!-- Generator banner -->
<meta name="generator"
content="mkdocs-{{ mkdocs_version }}, $theme-name$-$theme-version$" />
content="mkdocs-{{ mkdocs_version }}, $theme-name$-$theme-version$" />
{% endblock %}
<!-- Block: site title -->
@ -96,7 +96,7 @@
| default("Roboto Mono") %}
{% set font = text + ':300,400,400i,700|' + code | replace(' ', '+') %}
<link rel="stylesheet" type="text/css"
href="https://fonts.googleapis.com/css?family={{ font }}" />
href="https://fonts.googleapis.com/css?family={{ font }}" />
<style>
body, input {
font-family: "{{ text }}", "Helvetica Neue",

View File

@ -77,11 +77,11 @@
<!-- Repository containing source -->
<div class="md-flex__cell md-flex__cell--shrink">
<div class="md-header-nav__source">
{% if config.repo_url %}
{% include "partials/source.html" %}
{% endif %}
</div>
<div class="md-header-nav__source">
{% if config.repo_url %}
{% include "partials/source.html" %}
{% endif %}
</div>
</div>
</div>
</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">
<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 %}">
{{ nav_item.title }}
</a>
{% 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>
<!-- 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 %}">
{{ nav_item.title }}
</a>
{% 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

@ -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 %}