2022-11-16 09:25:50 +00:00
|
|
|
{%- macro plural(value, suffix='s') -%}
|
|
|
|
{%- if value != 1 -%}
|
|
|
|
{{suffix}}
|
|
|
|
{%- endif -%}
|
|
|
|
{%- endmacro -%}
|
|
|
|
|
|
|
|
{%- macro banner(src, href, alt, expand) %}
|
2022-11-15 01:38:50 +00:00
|
|
|
<a href="{{href|default(src)}}" rel="nofollow noopener">
|
|
|
|
<img onclick="{{expand|default('expandDesktopImage()')}}" alt="{{alt|default('site banner')}}" src="{{src|default(live_banner())}}">
|
2022-11-15 01:28:43 +00:00
|
|
|
</a>
|
2022-11-16 09:25:50 +00:00
|
|
|
{% endmacro -%}
|
2022-11-15 01:28:43 +00:00
|
|
|
|
2022-11-16 09:25:50 +00:00
|
|
|
{%- macro live_banner() %}
|
2022-11-15 01:28:43 +00:00
|
|
|
{% set path = "files/assets/images/" + SITE_NAME %}
|
|
|
|
{% if not v and os_path.exists(path + "/cached.webp") %}
|
|
|
|
{{ 'cached.webp' | asset_siteimg }}
|
|
|
|
{% elif os_path.exists(path + "/banners") %}
|
|
|
|
{{ random_image("banners") }}
|
|
|
|
{% else %}
|
|
|
|
{{ 'banner.webp' | asset_siteimg }}
|
|
|
|
{% endif %}
|
2022-11-16 09:25:50 +00:00
|
|
|
{% endmacro -%}
|
2022-11-15 01:28:43 +00:00
|
|
|
|
2022-11-16 09:25:50 +00:00
|
|
|
{%- macro random_image(assetdir) %}
|
2022-11-15 01:28:43 +00:00
|
|
|
{% set path = "assets/images/" + SITE_NAME + "/" + assetdir %}
|
|
|
|
{{ "/" + path + "/" + listdir('files/' + path)|random() + '?v=45' }}
|
2022-11-16 09:25:50 +00:00
|
|
|
{% endmacro -%}
|