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.
139 lines
4.3 KiB
HTML
139 lines
4.3 KiB
HTML
{% import "icon_macros.html" as i %}
|
|
|
|
{# ================== #}
|
|
{# === taxonomies === #}
|
|
{# ================== #}
|
|
|
|
{# === tags === #}
|
|
{%- macro tags(tags) -%}
|
|
<span class="tags">
|
|
{%- for tag in tags -%}
|
|
{%- set url = get_taxonomy_url(kind="tags", name=tag) -%}
|
|
<a class="tag" href="{{url}}">{{ tag }}</a>
|
|
{%- endfor -%}
|
|
</span>
|
|
{%- endmacro -%}
|
|
|
|
{# === author === #}
|
|
{%- macro authors(authors) -%}
|
|
<span class="authors">
|
|
{%- for author in authors -%}
|
|
{%- set url = get_taxonomy_url(kind="authors", name=author) -%}
|
|
<a class="author" href="{{url}}">{{ i::user(size="16px") }}{{ author }}</a>{% if not loop.last %}, {% endif %}
|
|
{%- endfor %}
|
|
</span>
|
|
{%- endmacro -%}
|
|
|
|
{# === translations === #}
|
|
{% macro translations(resource) %}
|
|
{% if resource.extra.translations %}
|
|
{% for ltag,lurl in resource.extra.translations %}
|
|
{% set lcfg = config.extra.translations[ltag] %}
|
|
<a href="{{lcfg.base_url}}{{lurl}}">{{lcfg.flag}}</a>
|
|
{% endfor %}
|
|
{% endif %}
|
|
{%- endmacro %}
|
|
|
|
{# === category === #}
|
|
{%- macro category(category) -%}
|
|
<span class="category">
|
|
{%- for cat in category -%}
|
|
{%- set url = get_taxonomy_url(kind="category", name=cat) -%}
|
|
<a class="cat" href="{{url}}">{{ i::folder(size="16px") }}{{ cat }}</a>
|
|
{%- endfor -%}
|
|
</span>
|
|
{%- endmacro -%}
|
|
|
|
{# === taxonomies === #}
|
|
{%- macro taxonomies(taxonomies) -%}
|
|
{%- if taxonomies.category -%}{{ macros::category(category=taxonomies.category )}}{%- endif -%}
|
|
{%- if taxonomies.authors -%}{{ macros::authors(authors=taxonomies.authors )}}{%- endif -%}
|
|
{%- if taxonomies.tags -%}{{ macros::tags(tags=taxonomies.tags )}}{%- endif -%}
|
|
{%- endmacro -%}
|
|
|
|
{%- macro date(date, icon=true, format="%d %B %Y", locale="fr_FR") -%}
|
|
{%- if date -%}{% if icon %}{{i::clock(size="16px")}}{% endif %}{{ date | date(format=format, locale=locale) }}{%- endif -%}
|
|
{%- endmacro -%}
|
|
|
|
{# =========================== #}
|
|
{# === resize static image === #}
|
|
{# =========================== #}
|
|
{% macro resize_static(path, width=160, height=160, op="fit_height") %}
|
|
{%- set resized = resize_image(path="../static" ~ path, width=width, height=height, op=op, quality=85) -%}
|
|
{{ resized.url }}
|
|
{%- endmacro resize_static %}
|
|
|
|
|
|
{# ===================== #}
|
|
{# === image gallery === #}
|
|
{# ===================== #}
|
|
{% macro gallery(images, height=200, single_line=false) %}
|
|
<div class="{% if single_line %}single-line-{% endif %}gallery">
|
|
<div class="images" {% if single_line %}style="width: {{images | length * 3/2 * height}}px; height: {{height+10}}px;"{% endif %}>
|
|
{% for img in images %}
|
|
{% set img_meta = get_image_metadata(path=img) %}
|
|
<a href="{{img}}"
|
|
data-pswp-width="{{img_meta.width}}"
|
|
data-pswp-height="{{img_meta.height}}">
|
|
<img src="{{ macros::resize_static(path=img, width=height, height=height) }}"/>
|
|
</a>
|
|
{% endfor %}
|
|
</div>
|
|
</div>
|
|
{% endmacro gallery %}
|
|
|
|
{% macro photoswipe_script(gallery="") %}
|
|
<script type="module">
|
|
import PhotoSwipeLightbox from '/javascript/photoswipe-lightbox.esm.js';
|
|
const lightbox = new PhotoSwipeLightbox({
|
|
gallery: '{{gallery}}',
|
|
children: 'a',
|
|
pswpModule: () => import('/javascript/photoswipe.esm.js'),
|
|
});
|
|
lightbox.init();
|
|
</script>
|
|
{% endmacro photoswipe_script %}
|
|
|
|
|
|
{# ========================= #}
|
|
{# === table of contents === #}
|
|
{# ========================= #}
|
|
{% macro toc(toc, level, depth) %}
|
|
{%- if level == 1 %}
|
|
<div class="toc">
|
|
<h3>{{config.extra.theme.toc_title}}</h3>
|
|
{%- endif %}
|
|
{%- if level != 1 %}
|
|
<ol class="h{{ level }}">
|
|
{%- endif %}
|
|
{%- for h in toc %}
|
|
{%- if level != 1 %}
|
|
<li><a href="{{ h.permalink | safe }}">{{ h.title }}</a>
|
|
{%- endif %}
|
|
{% if h.children and level <= depth -%}
|
|
{{ self::toc(toc=h.children, level=level+1, depth=depth, heading=false) }}
|
|
{%- endif %}
|
|
{%- if level != 1 -%}
|
|
</li>
|
|
{%- endif %}
|
|
{%- endfor %}
|
|
{%- if level != 1 %}
|
|
</ol>
|
|
{%- endif %}
|
|
{%- if level == 1 %}
|
|
</div>
|
|
{%- endif %}
|
|
{%- endmacro %}
|
|
|
|
|
|
{# =================== #}
|
|
{# === replace toc === #}
|
|
{# =================== #}
|
|
{% macro replace_toc(resource) %}
|
|
{%- set content = resource.content %}
|
|
{%- if content is containing("[TOC]") %}
|
|
{%- set content = content | replace(from="[TOC]", to=self::toc(toc=resource.toc, level=1, depth=resource.extra.toc_depth | default(value=6))) %}
|
|
{%- endif -%}
|
|
{{ content | safe }}
|
|
{%- endmacro %}
|