lvl0-website/themes/linkita/templates/macros/url.html

49 lines
1.4 KiB
HTML

{%- macro rel(there, here, base) -%}
{%- if here and there is starting_with(base) %}
{%- for _ in here %}
{%- if not loop.last %}
{{- "../" | safe }}
{%- endif %}
{%- endfor %}
{{- there | trim_start_matches(pat=base) | safe }}
{%- if config.extra.urls_to_index_html and there is ending_with("/") %}
{{- "index.html" }}
{%- endif %}
{%- else %}
{{- there | safe }}
{%- endif %}
{%- endmacro rel -%}
{%- macro get(url, bu="") -%}
{%- if url is starting_with("@") %}
{{- get_url(path=url) }}
{%- elif url is starting_with("$BASE_URL") %}
{%- if bu == "" %}{% set bu = get_url(path=``, lang=lang) %}{% endif %}
{{- bu | safe }}{{ url | trim_start_matches(pat="$BASE_URL") | safe }}
{%- else %}
{{- url | safe }}
{%- endif %}
{%- endmacro get -%}
{%- macro social_icon(icon, prl=false) -%}
{%- set icon_path = "icons/" ~ icon ~ ".svg" %}
{%- set meta = get_image_metadata(path=icon_path, allow_missing=true) %}
{%- if meta %}
{%- if prl %}
{{- get_url(path=icon_path) }}
{%- else %}
{{- icon_path | safe }}
{%- endif %}
{%- else %}
{{- "https://cdn.jsdelivr.net/npm/simple-icons/icons/" ~ icon ~ ".svg" | safe }}
{%- endif %}
{%- endmacro social_icon -%}
{%- macro cover_image(path, assets) -%}
{%- for asset in assets %}
{%- if asset is ending_with(path) %}
{{- asset | safe }}
{%- break %}
{%- endif %}
{%- endfor %}
{%- endmacro cover_image -%}