Přesunutí všech komponent do bloků

In order to be able to access section font-matter from within a page, a
section variable has to be set according to the page ancestor. All
navigation blocks have to be regenerated from within the page context.
master
Emil Miler 4 years ago
parent 025109fb8c
commit a36a55151a

@ -12,27 +12,31 @@
<div id="header"> <div id="header">
{% set current_section = get_section(path="_index.md") %} {% set current_section = get_section(path="_index.md") %}
<a href="{{ config.base_url }}">{{ config.title }}</a> <a href="{{ config.base_url }}">{{ config.title }}</a>
<span class="subtitle">{{ current_section.title }}</span> <span class="subtitle">{% block subtitle %}{{ current_section.title }}{% endblock %}</span>
</div> </div>
<div id="menu"> <div id="menu">
<ul> <ul>
{% for s in current_section.subsections %} {% block menu %}
{% set subsection = get_section(path=s) %} {% for s in current_section.subsections %}
<li {% if current_path == subsection.path %}class="active"{% endif %}> {% set subsection = get_section(path=s) %}
<a href="{{ subsection.permalink }}">{{ subsection.title }}</a> <li {% if current_path == subsection.path %}class="active"{% endif %}>
</li> <a href="{{ subsection.permalink }}">{{ subsection.title }}</a>
{% endfor %} </li>
{% endfor %}
{% endblock %}
</ul> </ul>
</div> </div>
<div id="content"> <div id="content">
<div id="nav"> <div id="nav">
{% if section.pages %} {% block nav %}
<ul> {% if section.pages %}
{% for post in section.pages %} <ul>
<li><a href="{{ post.permalink }}">{{ post.title }}</a></li> {% for post in section.pages %}
{% endfor %} <li><a href="{{ post.permalink }}">{{ post.title }}</a></li>
</ul> {% endfor %}
{% endif %} </ul>
{% endif %}
{% endblock %}
</div> </div>
<div id="main"> <div id="main">
{% block content%}{% endblock %} {% block content%}{% endblock %}

@ -1,5 +1,31 @@
{% extends "index.html" %} {% extends "index.html" %}
{% block subtitle %}
{% set current_section = get_section(path=page.ancestors[1]) %}
{{ current_section.title }}
{% endblock %}
{% block content %} {% block content %}
{{ page.content | safe }} {{ page.content | safe }}
{% endblock %} {% endblock %}
{% block menu %}
{% set global_section = get_section(path="_index.md") %}
{% for s in global_section.subsections %}
{% set subsection = get_section(path=s) %}
<li {% if current_path == subsection.path %}class="active"{% endif %}>
<a href="{{ subsection.permalink }}">{{ subsection.title }}</a>
</li>
{% endfor %}
{% endblock %}
{% block nav %}
{% if current_section.pages %}
<ul>
{% for post in current_section.pages %}
<li><a href="{{ post.permalink }}">{{ post.title }}</a></li>
{% endfor %}
</ul>
{% endif %}
{% endblock %}

@ -1,5 +1,9 @@
{% extends "index.html" %} {% extends "index.html" %}
{% block subtitle %}
{{ section.title }}
{% endblock %}
{% block content %} {% block content %}
<h1>{{ section.title }}</h1> <h1>{{ section.title }}</h1>
{{ section.content | safe }} {{ section.content | safe }}