1
4
Fork 1

Používání maker v šablonách

master
Emil Miler 4 years ago
parent dbb6fb0b80
commit 3878770f1d

@ -20,11 +20,7 @@
</ul> </ul>
</div> </div>
<div class="subnav"> <div class="subnav">
<ul> {{ macro::subnav() }}
{% for item in config.extra.menu %}
<li><a href="{{ item.path }}">{{ item.name }}</a></li>
{% endfor %}
</ul>
</div> </div>
</nav> </nav>
@ -39,9 +35,7 @@
</section> </section>
<div class="pagination"> <div class="pagination">
{% if paginator.previous %}<a href="{{ paginator.previous }}">&laquo; Předchozí stránka</a> |{% endif %} {{ macro::pagination() }}
<span>{{ paginator.current_index }} / {{ paginator.number_pagers }}</span>
{% if paginator.next %}| <a href="{{ paginator.next }}">Další stránka &raquo;</a>{% endif %}
</div> </div>
</main> </main>

@ -4,12 +4,6 @@
<main> <main>
<h2>Kategorie</h2> <h2>Kategorie</h2>
<hr> <hr>
{% if terms %} {{ macro::list_terms() }}
<ul>
{% for term in terms %}
<li><a href="{{ term.permalink }}">{{ term.name | capitalize() }}</a> ({{ term.pages | length }})</li>
{% endfor %}
</ul>
{% endif %}
</main> </main>
{% endblock content %} {% endblock content %}

@ -18,3 +18,65 @@
{% if recipe.date %}<span class="date">{{ recipe.date | date(format="%d.%m.%Y") }}</span>{% endif %} {% if recipe.date %}<span class="date">{{ recipe.date | date(format="%d.%m.%Y") }}</span>{% endif %}
</article> </article>
{% endmacro print_recipe %} {% endmacro print_recipe %}
{% macro pagination() %}
{% if paginator.previous %}<a href="{{ paginator.previous }}">&laquo; Předchozí stránka</a> |{% endif %}
<span>{{ paginator.current_index }} / {{ paginator.number_pagers }}</span>
{% if paginator.next %}| <a href="{{ paginator.next }}">Další stránka &raquo;</a>{% endif %}
{% endmacro pagination %}
{% macro subnav() %}
<ul>
{% for item in config.extra.menu %}
<li><a href="{{ item.path }}">{{ item.name }}</a></li>
{% endfor %}
</ul>
{% endmacro subnav %}
{% macro recipe_image() %}
{% for asset in page.assets %}
{% if asset is matching("[img.](jpg|png)$") %}
<a href="/{{ asset }}"><img src="{{ resize_image(path=asset, width=900, height=400, op="fill") }}" alt="Náhled"></a>
{% break %}
{% endif %}
{% endfor %}
{% endmacro recipe_image %}
{% macro recipe_meta() %}
{% if page.extra.portions %}<span class="tag">Porce: <strong>{{ page.extra.portions }}</strong></span>{% endif %}
{% if page.extra.time %}<span class="tag">Doba přípravy: <strong>{{ page.extra.time }} min</strong></span>{% endif %}
{% if page.extra.source %}<span class="tag">Zdroj: <strong>{{ page.extra.source }}</strong></span>{% endif %}
<a href="{{ config.extra.git }}/_edit/master/content/{{ page.relative_path }}" class="edit" title="Upravit"><span class="icon-pencil"></span></a>
{% endmacro recipe_meta %}
{% macro recipe_taxonomies() %}
{% if page.taxonomies.kategorie %}
{% set categories = page.taxonomies.kategorie %}
<div class="taglist">
Kategorie&nbsp;&ndash;&nbsp;
{% for term in categories %}
<span class="tag"><a href="{{ get_taxonomy_url(kind="kategorie", name=term) | safe }}">{{ term | capitalize() }}</a></span>
{% endfor %}
</div>
{% endif %}
{% if page.taxonomies.tagy %}
{% set tags = page.taxonomies.tagy %}
<div class="taglist">
Tagy&nbsp;&ndash;&nbsp;
{% for term in tags %}
<span class="tag"><a href="{{ get_taxonomy_url(kind="tagy", name=term) | safe }}">{{ term | capitalize() }}</a></span>
{% endfor %}
</div>
{% endif %}
{% endmacro recipe_taxonomies %}
{% macro list_terms() %}
{% if terms %}
<ul>
{% for term in terms %}
<li><a href="{{ term.permalink }}">{{ term.name | capitalize() }}</a> ({{ term.pages | length }})</li>
{% endfor %}
</ul>
{% endif %}
{% endmacro list_terms %}

@ -7,44 +7,17 @@
<h2>{{ page.title | upper }}</h2> <h2>{{ page.title | upper }}</h2>
<hr> <hr>
{% for asset in page.assets %} {{ macro::recipe_image() }}
{% if asset is matching("[img.](jpg|png)$") %}
<a href="/{{ asset }}"><img src="{{ resize_image(path=asset, width=900, height=400, op="fill") }}" alt="Náhled"></a>
{% break %}
{% endif %}
{% endfor %}
{% if page.extra.image %}<img src="{{ page.extra.image }}" alt="Náhled">{% endif %}
<div class="meta"> <div class="meta">
{% if page.extra.portions %}<span class="tag">Porce:&nbsp;<strong>{{ page.extra.portions }}</strong></span>{% endif %} {{ macro::recipe_meta() }}
{% if page.extra.time %}<span class="tag">Doba přípravy:&nbsp;<strong>{{ page.extra.time }}&nbsp;min</strong></span>{% endif %}
{% if page.extra.source %}<span class="tag">Zdroj:&nbsp;<strong>{{ page.extra.source }}</strong></span>{% endif %}
<a href="{{ config.extra.git }}/_edit/master/content/{{ page.relative_path }}" class="edit" title="Upravit"><span class="icon-pencil"></span></a>
</div> </div>
{{ page.content | safe }} {{ page.content | safe }}
<hr> <hr>
{% if page.taxonomies.kategorie %} {{ macro::recipe_taxonomies() }}
{% set categories = page.taxonomies.kategorie %}
<div class="taglist">
Kategorie&nbsp;&ndash;&nbsp;
{% for term in categories %}
<span class="tag"><a href="{{ get_taxonomy_url(kind="kategorie", name=term) | safe }}">{{ term | capitalize() }}</a></span>
{% endfor %}
</div>
{% endif %}
{% if page.taxonomies.tagy %}
{% set tags = page.taxonomies.tagy %}
<div class="taglist">
Tagy&nbsp;&ndash;&nbsp;
{% for term in tags %}
<span class="tag"><a href="{{ get_taxonomy_url(kind="tagy", name=term) | safe }}">{{ term | capitalize() }}</a></span>
{% endfor %}
</div>
{% endif %}
</main> </main>
{% endblock content %} {% endblock content %}

@ -4,12 +4,6 @@
<main> <main>
<h2>Tagy</h2> <h2>Tagy</h2>
<hr> <hr>
{% if terms %} {{ macro::list_terms() }}
<ul>
{% for term in terms %}
<li><a href="{{ term.permalink }}">{{ term.name | capitalize() }}</a> ({{ term.pages | length }})</li>
{% endfor %}
</ul>
{% endif %}
</main> </main>
{% endblock content %} {% endblock content %}

Loading…
Cancel
Save