forked from kittv/web
1
0
Fork 0
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
web/templates/macros.html

153 lines
4.1 KiB
HTML

{% macro nav_list_items(items) %}
{% if items %}
<ul>
{% for item in items %}
<li><a href="{{ item.path }}">{{ item.name }}</a></li>
{% endfor %}
</ul>
{% endif %}
{% endmacro %}
{% macro nav_list_items_recursive(items) %}
{% if items %}
<ul>
{% for item in items %}
{% set section = get_section(path=item.path~"/_index.md") %}
<li
{% if section.extra.color %}
style="--color: {{ section.extra.color }}"
{% else %}
style="--color: #5E81AC"
{% endif %}
>
<a href="{{ section.permalink }}">{{ section.title }}</a>
{% if section.subsections %}
<ul>
{% for subsection in section.subsections %}
{% set subsection = get_section(path=subsection) %}
<li>
<a href="{{ subsection.permalink }}">
<span class="icon">
{% if subsection.extra.icon %}
{{ subsection.extra.icon | safe }}
{% else %}
&clubs;
{% endif %}
</span>
{{ subsection.title }}
</a>
</li>
{% endfor %}
</ul>
{% endif %}
</li>
{% endfor %}
</ul>
{% endif %}
{% endmacro %}
{% macro breadcrumbs(page) %}
<div class="breadcrumbs">
<div class="wrap">
<a href="{{ config.base_url }}" class="home"><img src="{{ get_url(path="home.svg") }}" alt="Home"></a>
<ul>
{% for ancestor in page.ancestors %}
{% if loop.first %}{% continue %}{% endif %}
{% set section = get_section(path=ancestor) %}
<li><a href="{{ section.permalink }}">{{ section.title }}</a></li>
{% endfor %}
<li><a href="{{ page.permalink }}">{{ page.title }}</a></li>
</ul>
</div>
</div>
{% endmacro %}
{% macro list_posts(section) %}
{% for post in section.pages %}
{% if post.extra.expiration and post.extra.expiration | date(format="%s") | int + 86400 < now(timestamp=true) %}
{% continue %}
{% endif %}
<article>
<div class="title">
<a href="{{ post.permalink }}">{{ post.title }}</a>
</div>
{% if post.summary %}
{{ post.summary | safe }}
{% else %}
{{ post.content | safe }}
{% endif %}
{% if post.date %}
<div class="date">{{ post.date | date(format="%d.%m.%Y")}}</div>
{% endif %}
</article>
{% endfor %}
{% endmacro %}
{% macro list_external_links(section) %}
{% for post in section.pages %}
<a href="
{% if post.extra.link %}
{{ post.extra.link }}
{% else %}
{{ post.permalink }}
{% endif %}
">
<article
{% if post.extra.color %}
style="border-color: {{ post.extra.color }}"
{% endif %}
>
<div class="title">
{% if post.extra.logo %}
<img src="{{ post.permalink ~ "../" ~ post.extra.logo }}" alt="{{ post.title }}">
{% else %}
{{ post.title }}
{% endif %}
</div>
{{ post.content | safe }}
</article>
</a>
{% endfor %}
{% endmacro %}
{% macro list_people() %}
{% for page in section.pages %}
<article>
{{ macro::profile_picture(person=page) }}
<div class="info">
<div>
<div class="name"><a href="{{ page.permalink }}">{{ page.title }}</a></div>
{% if page.extra.email %}
<div class="role">{{ page.extra.role }}</div>
{% endif %}
</div>
<div class="other">
{% if page.extra.email %}
<div><a href="mailto:{{ page.extra.email }}">{{ page.extra.email }}</a></div>
{% endif %}
{% if page.extra.phone %}
<div><a href="tel:{{ page.extra.phone }}">{{ page.extra.phone }}</a></div>
{% endif %}
{% if page.extra.time %}
<div title="Konzultační hodiny">{{ page.extra.time | safe }}</div>
{% endif %}
</div>
</div>
</article>
{% endfor %}
{% endmacro %}
{% macro profile_picture(person) %}
{% set_global img_found = 0 %}
{% for asset in person.assets %}
{% if asset is matching("img.(jpg|png)$") %}
{% set_global img_found = 1 %}
<img src="{{ resize_image(path=asset, width=128, height=128, op="fill") }}" alt="{{ person.title }}"></a>
{% break %}
{% endif %}
{% endfor %}
{% if not img_found == 1 %}
<img src="{{ get_url(path="placeholder-avatar.jpg") }}" alt="{{ person.title }}"></a>
{% endif %}
{% endmacro %}