1bit.pw/templates/macros.html

41 lines
1.2 KiB
HTML

{% macro link(url) %}
{%- if url is starting_with("/") or url is starting_with("./") -%}
{{ get_url(path=url, trailing_slash=false) | safe }}
{%- else -%}
{{ url | safe }}
{%- endif -%}
{% endmacro link %}
{% macro is_active_nav(url, curr_url) %}
{%- if url == get_url(path="/") -%}
{{ url == curr_url }}
{%- else -%}
{{ curr_url is starting_with(url) }}
{%- endif -%}
{% endmacro is_active_nav %}
{% macro meta_desc(ctx) %}
{%- if ctx.description -%}
{{ ctx.description }}
{%- else -%}
{%- if ctx.summary -%}
{{ ctx.summary | striptags | replace(from="
", to=" ") | trim }}
{%- else -%}
{{ ctx.content | striptags | replace(from="
", to=" ") | trim }}
{%- endif -%}
{%- endif -%}
{% endmacro meta_desc %}
{% macro status_badge(status, desc, link, color, label="status") %}
{{ self::badge(type="badge", scope=label ~ "-" ~ status ~ "-" ~ color, desc=desc, link=link) }}
{% endmacro status_badge %}
{% macro badge(type, scope, desc, link) %}
{% if link %}
<a class="badge" href="{{ link }}"><img alt="{{ desc }}" src="https://img.shields.io/{{ type }}/{{ scope }}" /></a>
{% else %}
<img class="badge" alt="{{ desc }}" src="https://img.shields.io/{{ type }}/{{ scope }}" />
{% endif %}
{% endmacro link %}