forked from em/receptty.org
Použití makra pro výpis receptu
This commit is contained in:
parent
20d0c57c89
commit
4f88150e94
@ -1,3 +1,4 @@
|
||||
{% import "macros.html" as macro %}
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
@ -31,30 +32,9 @@
|
||||
<h2>Nejnovější recepty</h2>
|
||||
<hr>
|
||||
<section class="list">
|
||||
|
||||
{% for page in paginator.pages %}
|
||||
<article>
|
||||
|
||||
<a href="{{ page.permalink }}">
|
||||
{% set_global image_found = 0 %}
|
||||
{% for asset in page.assets %}
|
||||
{% if asset is matching("[img.](jpg|png)$") %}
|
||||
<img src="{{ resize_image(path=asset, width=300, height=300, op="fill") }}" alt="Náhled">
|
||||
{% set_global image_found = 1 %}
|
||||
{% break %}
|
||||
{% endif %}
|
||||
{{ macro::print_recipe(recipe=page) }}
|
||||
{% endfor %}
|
||||
{% if image_found == 0 %}
|
||||
<img src="/temp.jpg" alt="Náhradní obrázek">
|
||||
{% endif %}
|
||||
{% set_global image_found = 0 %}
|
||||
{% if page.title %}<h3>{{ page.title }}</h3>{% endif %}
|
||||
</a>
|
||||
{% if page.date %}<span class="date">{{ page.date | date(format="%d.%m.%Y") }}</span>{% endif %}
|
||||
|
||||
</article>
|
||||
{% endfor %}
|
||||
|
||||
</section>
|
||||
|
||||
<div class="pagination">
|
||||
|
@ -6,26 +6,7 @@
|
||||
<hr>
|
||||
<section class="list">
|
||||
{% for page in term.pages %}
|
||||
<article>
|
||||
|
||||
<a href="{{ page.permalink }}">
|
||||
{% set_global image_found = 0 %}
|
||||
{% for asset in page.assets %}
|
||||
{% if asset is matching("[img.](jpg|png)$") %}
|
||||
<img src="{{ resize_image(path=asset, width=300, height=300, op="fill") }}" alt="Náhled">
|
||||
{% set_global image_found = 1 %}
|
||||
{% break %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% if image_found == 0 %}
|
||||
<img src="/temp.jpg" alt="Náhradní obrázek">
|
||||
{% endif %}
|
||||
{% set_global image_found = 0 %}
|
||||
{% if page.title %}<h3>{{ page.title }}</h3>{% endif %}
|
||||
</a>
|
||||
{% if page.date %}<span class="date">{{ page.date | date(format="%d.%m.%Y") }}</span>{% endif %}
|
||||
|
||||
</article>
|
||||
{{ macro::print_recipe(recipe=page) }}
|
||||
{% endfor %}
|
||||
</section>
|
||||
</main>
|
||||
|
20
templates/macros.html
Normal file
20
templates/macros.html
Normal file
@ -0,0 +1,20 @@
|
||||
{% macro print_recipe(recipe) %}
|
||||
<article>
|
||||
<a href="{{ recipe.permalink }}">
|
||||
{% set_global image_found = 0 %}
|
||||
{% for asset in recipe.assets %}
|
||||
{% if asset is matching("[img.](jpg|png)$") %}
|
||||
<img src="{{ resize_image(path=asset, width=300, height=300, op="fill") }}" alt="Náhled">
|
||||
{% set_global image_found = 1 %}
|
||||
{% break %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% if image_found == 0 %}
|
||||
<img src="/temp.jpg" alt="Náhradní obrázek">
|
||||
{% endif %}
|
||||
{% set_global image_found = 0 %}
|
||||
{% if recipe.title %}<h3>{{ recipe.title }}</h3>{% endif %}
|
||||
</a>
|
||||
{% if recipe.date %}<span class="date">{{ recipe.date | date(format="%d.%m.%Y") }}</span>{% endif %}
|
||||
</article>
|
||||
{% endmacro print_recipe %}
|
@ -9,7 +9,10 @@
|
||||
<input type="text" id="name" placeholder="Název">
|
||||
</div>
|
||||
<section class="list">
|
||||
list
|
||||
{% set section = get_section(path="_index.md") %}
|
||||
{% for page in section.pages %}
|
||||
{{ macro::print_recipe(recipe=page) }}
|
||||
{% endfor %}
|
||||
</section>
|
||||
</main>
|
||||
{% endblock content %}
|
||||
|
@ -6,27 +6,7 @@
|
||||
<hr>
|
||||
<section class="list">
|
||||
{% for page in term.pages %}
|
||||
<article>
|
||||
|
||||
<a href="{{ page.permalink }}">
|
||||
{% set_global image_found = 0 %}
|
||||
{% for asset in page.assets %}
|
||||
{% if asset is matching("[img.](jpg|png)$") %}
|
||||
<img src="{{ resize_image(path=asset, width=300, height=300, op="fill") }}" alt="Náhled">
|
||||
{% set_global image_found = 1 %}
|
||||
{% break %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% if image_found == 0 %}
|
||||
<img src="/temp.jpg" alt="Náhradní obrázek">
|
||||
{% endif %}
|
||||
{% set_global image_found = 0 %}
|
||||
</a>
|
||||
|
||||
{% if page.title %}<a href="{{ page.permalink }}"><h3>{{ page.title }}</h3></a>{% endif %}
|
||||
{% if page.date %}<span class="date">{{ page.date | date(format="%d.%m.%Y") }}</span>{% endif %}
|
||||
|
||||
</article>
|
||||
{{ macro::print_recipe(recipe=page) }}
|
||||
{% endfor %}
|
||||
</section>
|
||||
</main>
|
||||
|
Loading…
Reference in New Issue
Block a user