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.
148 lines
4.4 KiB
HTML
148 lines
4.4 KiB
HTML
{# ============= #}
|
|
{# === KATEX === #}
|
|
{# ============= #}
|
|
{% macro katex() %}
|
|
<link rel="stylesheet" href="/katex/katex.css">
|
|
<script defer src="/katex/katex.js"></script>
|
|
<script defer src="/katex/auto-render.js"></script>
|
|
<script>
|
|
document.addEventListener("DOMContentLoaded", function() {
|
|
renderMathInElement(document.body, {
|
|
delimiters: [
|
|
{left: "££", right: "££", display: true},
|
|
{left: "$", right: "$", display: false},
|
|
]
|
|
});
|
|
});
|
|
</script>
|
|
{% endmacro katex %}
|
|
|
|
|
|
{# =========================== #}
|
|
{# === 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) %}
|
|
{{ resized.url }}
|
|
{% endmacro resize_static %}
|
|
|
|
|
|
{# ========================= #}
|
|
{# === 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 %}
|
|
|
|
{# ================== #}
|
|
{# === breadcrumb === #}
|
|
{# ================== #}
|
|
{% macro breadcrumb(path) %}
|
|
{% set cur = "/" %}
|
|
{% for elt in path %}
|
|
{% set_global cur = cur ~ elt ~ "/" %}
|
|
/ <a href="{{cur}}">{{ elt }}</a>
|
|
{% endfor %}
|
|
{%- endmacro %}
|
|
|
|
{# === sub pages and sub section === #}
|
|
{% macro sub(section) %}
|
|
<span class="breadcrumb-next">content <i class="fa fa-caret-down"></i>
|
|
<ul>
|
|
{% for section in section.subsections %}
|
|
{% set section = get_section(path=section, metadata_only=true) %}
|
|
<li><i class="fa fa-folder"></i> <a href="{{ section.permalink }}">{{ section.title }}</a></li>
|
|
{% endfor %}
|
|
{% for page in section.pages %}
|
|
<li><i class="fa fa-file-o"></i> <a href="{{ page.permalink }}">{{ page.title }}</a></li>
|
|
{% endfor %}
|
|
</ul></span>
|
|
{%- endmacro %}
|
|
|
|
{# ================== #}
|
|
{# === 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">
|
|
<i class="fa fa-user-circle-o"></i>
|
|
{%- for author in authors -%}
|
|
{%- set url = get_taxonomy_url(kind="authors", name=author) -%}
|
|
<a class="author" href="{{url}}">{{ 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 class="fa fa-bookmark"></i> {{ 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 -%}
|