The big shortcode cleanup

This commit is contained in:
daudix
2024-10-17 17:00:35 +03:00
parent d60dfa8496
commit 8bf69a5d71
26 changed files with 331 additions and 226 deletions

View File

@ -13,12 +13,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Add `config.extra.show_backlinks` config variable for showing the backlinks button for linked articles in the article's quick actions. - Add `config.extra.show_backlinks` config variable for showing the backlinks button for linked articles in the article's quick actions.
- Add `fediverse:creator` meta tag. - Add `fediverse:creator` meta tag.
- Add `title` class for use on `<strong>`. - Add `title` class for use on `<strong>`.
- Add missing translation strings for author separator and conjunctions.
- Add shortcode for Mastodon post embedding.
- Add support for Fuse.js search (#101). - Add support for Fuse.js search (#101).
- Add the ability to set video attributes via shortcode.
### Changed ### Changed
- Make `emoji` class available outside of comments. - Make `emoji` class available outside of comments.
- Make the code and styling for article cards much cleaner. - Make the code and styling for article cards much cleaner.
- Make the shortcodes code much cleaner.
- Remove top/bottom margin from the first/last element in `<aside>`. - Remove top/bottom margin from the first/last element in `<aside>`.
- Rename `show_read_time` to `show_reading_time`. - Rename `show_read_time` to `show_reading_time`.
- Use Zola's built-in reading time variable instead of the custom implementation (#102). - Use Zola's built-in reading time variable instead of the custom implementation (#102).

View File

@ -167,7 +167,7 @@ csp = [
{ directive = "media-src", domains = ["'self'", "https:", "data:"] }, { directive = "media-src", domains = ["'self'", "https:", "data:"] },
{ directive = "script-src", domains = ["'self'", "'unsafe-inline'"] }, { directive = "script-src", domains = ["'self'", "'unsafe-inline'"] },
{ directive = "style-src", domains = ["'self'", "'unsafe-inline'"] }, { directive = "style-src", domains = ["'self'", "'unsafe-inline'"] },
{ directive = "frame-src", domains = ["https://player.vimeo.com", "https://www.youtube-nocookie.com"] }, { directive = "frame-src", domains = ["https://player.vimeo.com", "https://www.youtube-nocookie.com", "https://toot.community"] },
{ directive = "connect-src", domains = ["https:"] }, { directive = "connect-src", domains = ["https:"] },
] ]
# Display outlines around all elements for debugging purposes # Display outlines around all elements for debugging purposes

View File

@ -213,17 +213,25 @@ Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor i
For videos it's all the same except for a few differences: `no_hover` and `url_min` variables are not available. For videos it's all the same except for a few differences: `no_hover` and `url_min` variables are not available.
Additionally, the following [attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/video#attributes) can be set:
- `autoplay`: Start playing the video automatically.
- `controls`: Display video controls such as volume control, seeking and pause/resume.
- `loop`: Play the video again once it ends.
- `muted`: Turn off the audio by default.
- `playsinline`: Prevent the video from playing in fullscreen by default (depends on the browser).
```jinja2 ```jinja2
{{/* video(url="video.webm", alt="This is a video") */}} {{/* video(url="video.webm", alt="This is a video", controls=true) */}}
``` ```
<figure> <figure>
{{ video(url="https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.webm", alt="Red flower wakes up") }} {{ video(url="https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.webm", alt="Red flower wakes up", controls=true) }}
<figcaption>WebM video example from MDN</figcaption> <figcaption>WebM video example from MDN</figcaption>
</figure> </figure>
<figure> <figure>
{{ video(url="https://upload.wikimedia.org/wikipedia/commons/transcoded/0/0e/Duckling_preening_%2881313%29.webm/Duckling_preening_%2881313%29.webm.720p.vp9.webm", alt="Duckling preening", full_bleed=true) }} {{ video(url="https://upload.wikimedia.org/wikipedia/commons/transcoded/0/0e/Duckling_preening_%2881313%29.webm/Duckling_preening_%2881313%29.webm.720p.vp9.webm", alt="Duckling preening", full_bleed=true, controls=true) }}
<figcaption>Duckling preening</figcaption> <figcaption>Duckling preening</figcaption>
</figure> </figure>
@ -295,6 +303,22 @@ Available variables are:
{{ vimeo(id="869483483") }} {{ vimeo(id="869483483") }}
#### Mastodon
Allows to embed a Mastodon post.
Available variables are:
- `host`: The instance on which the post resides. If not set, it will fallback to the one set in the `[extra.comments]` section of `config.toml`.
- `user`: The poster. If not set, it will fallback to the one set in the `[extra.comments]` section of `config.toml`.
- `id`: The ID of the post, usually at the end of the URL.
```jinja2
{{/* mastodon(host="toot.community", user="sungsphinx", id="111789185826519979") */}}
```
{{ mastodon(host="toot.community", user="sungsphinx", id="111789185826519979") }}
### Description List (`<dl>`) ### Description List (`<dl>`)
```html ```html

View File

@ -18,6 +18,8 @@ Coffee = "القهوة"
all_tags = "انظر جميع العلامات" all_tags = "انظر جميع العلامات"
archived = "الأرشيف" archived = "الأرشيف"
author = "الكاتب" author = "الكاتب"
author_conjunction = " و "
author_separator = "، "
backlinks = "الروابط الخلفية" backlinks = "الروابط الخلفية"
blog_post_author = "كاتب منشور المدونة" blog_post_author = "كاتب منشور المدونة"
boosts_from = "$INSTANCE التعزيزات من" boosts_from = "$INSTANCE التعزيزات من"

View File

@ -18,6 +18,8 @@ Coffee = "Coffee"
all_tags = "See all tags" all_tags = "See all tags"
archived = "Archived" archived = "Archived"
author = "Author" author = "Author"
author_conjunction = " and "
author_separator = ", "
backlinks = "Backlinks" backlinks = "Backlinks"
blog_post_author = "Blog post author" blog_post_author = "Blog post author"
boosts_from = "Boosts from $INSTANCE" boosts_from = "Boosts from $INSTANCE"

View File

@ -18,6 +18,8 @@ Coffee = "Café"
all_tags = "Ver todas las etiquetas" all_tags = "Ver todas las etiquetas"
archived = "Archivado" archived = "Archivado"
author = "Autor" author = "Autor"
author_conjunction = " y "
author_separator = ", "
backlinks = "Enlaces de retroceso" backlinks = "Enlaces de retroceso"
blog_post_author = "Autor del post" blog_post_author = "Autor del post"
boosts_from = "Boosts de $INSTANCE" boosts_from = "Boosts de $INSTANCE"

View File

@ -18,6 +18,8 @@ Coffee = "قهوه"
all_tags = "دیدن تمامی برچسب ها" all_tags = "دیدن تمامی برچسب ها"
archived = "بایگانی شده" archived = "بایگانی شده"
author = "نویسنده" author = "نویسنده"
author_conjunction = " و "
author_separator = "، "
backlinks = "بک لینک ها" backlinks = "بک لینک ها"
blog_post_author = "نویسنده‌ی این مطلب" blog_post_author = "نویسنده‌ی این مطلب"
boosts_from = "$INSTANCE تقویت از" boosts_from = "$INSTANCE تقویت از"

View File

@ -18,6 +18,8 @@ Coffee = "Kopi"
all_tags = "Lihat semua tag" all_tags = "Lihat semua tag"
archived = "Diarkibkan" archived = "Diarkibkan"
author = "Pengarang" author = "Pengarang"
author_conjunction = " dan "
author_separator = ", "
backlinks = "Pautan balik" backlinks = "Pautan balik"
blog_post_author = "Pengarang siaran blog" blog_post_author = "Pengarang siaran blog"
boosts_from = "Galakkan dari $INSTANCE" boosts_from = "Galakkan dari $INSTANCE"

View File

@ -22,6 +22,8 @@ Coffee = "Кофе"
all_tags = "Показать все теги" all_tags = "Показать все теги"
archived = "Архив" archived = "Архив"
author = "Автор" author = "Автор"
author_conjunction = " и "
author_separator = ", "
backlinks = "Обратные ссылки" backlinks = "Обратные ссылки"
blog_post_author = "Автор блог-поста" blog_post_author = "Автор блог-поста"
boosts_from = "Продвижения с $INSTANCE" boosts_from = "Продвижения с $INSTANCE"

View File

@ -19,6 +19,8 @@ Coffee = "赞助"
all_tags = "查看所有标签" all_tags = "查看所有标签"
archived = "归档" archived = "归档"
author = "作者" author = "作者"
author_conjunction = "和"
author_separator = "、"
backlinks = "反向链接" backlinks = "反向链接"
blog_post_author = "博客作者" blog_post_author = "博客作者"
boosts_from = "来自 $INSTANCE 的转发" boosts_from = "来自 $INSTANCE 的转发"

View File

@ -1,4 +1,5 @@
iframe { iframe {
display: block;
margin: 1rem auto; margin: 1rem auto;
box-shadow: var(--edge-highlight), var(--shadow); box-shadow: var(--edge-highlight), var(--shadow);
border: none; border: none;
@ -7,8 +8,13 @@ iframe {
width: 100%; width: 100%;
max-width: 100%; max-width: 100%;
&.youtube-embed, &.mastodon-embed {
&.vimeo-embed { aspect-ratio: 3 / 4;
width: min(calc(var(--container-width) / 2), 100%);
}
&.vimeo-embed,
&.youtube-embed {
aspect-ratio: 16 / 9; aspect-ratio: 16 / 9;
} }

View File

@ -4,13 +4,13 @@
{%- set rel_attributes = [] -%} {%- set rel_attributes = [] -%}
{%- if config.markdown.external_links_target_blank -%} {%- if config.markdown.external_links_target_blank -%}
{%- set rel_attributes = rel_attributes | concat(with="noopener") -%} {%- set rel_attributes = rel_attributes | concat(with="noopener") -%}
{%- endif -%} {%- endif -%}
{%- if config.markdown.external_links_no_follow -%} {%- if config.markdown.external_links_no_follow -%}
{%- set rel_attributes = rel_attributes | concat(with="nofollow") -%} {%- set rel_attributes = rel_attributes | concat(with="nofollow") -%}
{%- endif -%} {%- endif -%}
{%- if config.markdown.external_links_no_referrer -%} {%- if config.markdown.external_links_no_referrer -%}
{%- set rel_attributes = rel_attributes | concat(with="noreferrer") -%} {%- set rel_attributes = rel_attributes | concat(with="noreferrer") -%}
{%- endif -%} {%- endif -%}
{# Return the array of rel attributes joined by a space #} {# Return the array of rel attributes joined by a space #}

View File

@ -18,57 +18,57 @@ NOTE: If the logic for pluralization is modified, it needs to be replicated on t
Files: static/js/searchElasticlunr.js and its minified version at static/js/searchElasticlunr.min.js Files: static/js/searchElasticlunr.js and its minified version at static/js/searchElasticlunr.min.js
Function name: getPluralizationKey -#} Function name: getPluralizationKey -#}
{% macro translate(key, number=-1, language_strings="", default="", replace=true) %} {% macro translate(key, number=-1, language_strings="", default="", replace=true) %}
{%- set slavic_plural_languages = ["uk", "be", "bs", "hr", "ru", "sr"] -%} {%- set slavic_plural_languages = ["uk", "be", "bs", "hr", "ru", "sr"] -%}
{%- set key_prefix = "" -%} {%- set key_prefix = "" -%}
{#- `zero_` and `one_` are common cases. We handle "many" (plural) later, after language-specific pluralization -#} {#- `zero_` and `one_` are common cases. We handle "many" (plural) later, after language-specific pluralization -#}
{%- if number == 0 -%} {%- if number == 0 -%}
{%- set key_prefix = "zero_" -%} {%- set key_prefix = "zero_" -%}
{%- elif number == 1 -%} {%- elif number == 1 -%}
{%- set key_prefix = "one_" -%} {%- set key_prefix = "one_" -%}
{%- endif -%} {%- endif -%}
{#- Pluralization -#} {#- Pluralization -#}
{%- if number != -1 and key_prefix == "" -%} {%- if number != -1 and key_prefix == "" -%}
{#- Arabic -#} {#- Arabic -#}
{%- if lang == "ar" -%} {%- if lang == "ar" -%}
{%- set modulo = number % 100 -%} {%- set modulo = number % 100 -%}
{%- if number == 2 -%} {%- if number == 2 -%}
{%- set key_prefix = "two_" -%} {%- set key_prefix = "two_" -%}
{%- elif modulo >= 3 and modulo <= 10 -%} {%- elif modulo >= 3 and modulo <= 10 -%}
{%- set key_prefix = "few_" -%} {%- set key_prefix = "few_" -%}
{%- else -%} {%- else -%}
{%- set key_prefix = "many_" -%} {%- set key_prefix = "many_" -%}
{%- endif -%} {%- endif -%}
{#- Slavic languages like Russian or Ukrainian -#} {#- Slavic languages like Russian or Ukrainian -#}
{%- elif lang in slavic_plural_languages -%} {%- elif lang in slavic_plural_languages -%}
{%- set modulo10 = number % 10 -%} {%- set modulo10 = number % 10 -%}
{%- set modulo100 = number % 100 -%} {%- set modulo100 = number % 100 -%}
{%- if modulo10 == 1 and modulo100 != 11 -%} {%- if modulo10 == 1 and modulo100 != 11 -%}
{%- set key_prefix = "one_" -%} {%- set key_prefix = "one_" -%}
{%- elif modulo10 >= 2 and modulo10 <= 4 -%} {%- elif modulo10 >= 2 and modulo10 <= 4 -%}
{%- if modulo100 >= 12 and modulo100 <= 14 -%} {%- if modulo100 >= 12 and modulo100 <= 14 -%}
{%- set key_prefix = "many_" -%} {%- set key_prefix = "many_" -%}
{%- else -%} {%- else -%}
{%- set key_prefix = "few_" -%} {%- set key_prefix = "few_" -%}
{%- endif -%} {%- endif -%}
{%- else -%} {%- else -%}
{%- set key_prefix = "many_" -%} {%- set key_prefix = "many_" -%}
{%- endif -%} {%- endif -%}
{%- else -%} {%- else -%}
{#- Default pluralization -#} {#- Default pluralization -#}
{#- Zero and one are already handled -#} {#- Zero and one are already handled -#}
{%- set key_prefix = "many_" -%} {%- set key_prefix = "many_" -%}
{%- endif -%} {%- endif -%}
{%- endif -%} {%- endif -%}
{#- Translated string -#} {#- Translated string -#}
{%- set final_key = key_prefix ~ key -%} {%- set final_key = key_prefix ~ key -%}
{%- set translated_text = language_strings[final_key] | default(value=default) | safe -%} {%- set translated_text = language_strings[final_key] | default(value=default) | safe -%}
{#- Replace $NUMBER with the number -#} {#- Replace $NUMBER with the number -#}
{%- if replace -%} {%- if replace -%}
{%- set translated_text = translated_text | replace(from="$NUMBER", to=number | as_str) -%} {%- set translated_text = translated_text | replace(from="$NUMBER", to=number | as_str) -%}
{%- endif -%} {%- endif -%}
{{- translated_text -}} {{- translated_text -}}
{% endmacro translate %} {% endmacro translate %}

View File

@ -10,9 +10,9 @@
{%- endif -%} {%- endif -%}
{%- if page.extra.comments.user -%} {%- if page.extra.comments.user -%}
{%- set username = page.extra.comments.user -%} {%- set user = page.extra.comments.user -%}
{%- else %} {%- else %}
{%- set username = config.extra.comments.user -%} {%- set user = config.extra.comments.user -%}
{%- endif -%} {%- endif -%}
{%- set id = page.extra.comments.id -%} {%- set id = page.extra.comments.id -%}
@ -28,7 +28,7 @@
decoding="async" decoding="async"
loading="lazy" loading="lazy"
{%- endif -%} {%- endif -%}
src="https://api.qrserver.com/v1/create-qr-code/?data=https://{{ host }}/@{{ username }}/{{ id }}" src="https://api.qrserver.com/v1/create-qr-code/?data=https://{{ host }}/@{{ user }}/{{ id }}"
/> />
{%- endif -%} {%- endif -%}
<h2>{{ macros_translate::translate(key="comments", default="Comments", language_strings=language_strings) }}</h2> <h2>{{ macros_translate::translate(key="comments", default="Comments", language_strings=language_strings) }}</h2>
@ -37,7 +37,7 @@
<button id="load-comments" class="inline-button" onclick="loadComments()"> <button id="load-comments" class="inline-button" onclick="loadComments()">
{{- macros_translate::translate(key="load_comments", default="Load Comments", language_strings=language_strings) -}} {{- macros_translate::translate(key="load_comments", default="Load Comments", language_strings=language_strings) -}}
</button> </button>
<a class="inline-button colored external" href="https://{{ host }}/@{{ username }}/{{ id }}" rel="{{ rel_attributes }}"> <a class="inline-button colored external" href="https://{{ host }}/@{{ user }}/{{ id }}" rel="{{ rel_attributes }}">
{{- macros_translate::translate(key="open_post", default="Open Post", language_strings=language_strings) -}} {{- macros_translate::translate(key="open_post", default="Open Post", language_strings=language_strings) -}}
</a> </a>
</div> </div>
@ -129,7 +129,7 @@
const isReply = status.in_reply_to_id !== "{{ id }}"; const isReply = status.in_reply_to_id !== "{{ id }}";
let op = false; let op = false;
if (status.account.acct == "{{ username }}") { if (status.account.acct == "{{ user }}") {
op = true; op = true;
} }

View File

@ -4,50 +4,50 @@
content="default-src 'self' content="default-src 'self'
{%- if config.extra.csp -%} {%- if config.extra.csp -%}
{#- Initialise a base script-src directive -#} {#- Initialise a base script-src directive -#}
{%- set script_src = "script-src 'self'" -%} {%- set script_src = "script-src 'self'" -%}
{#- Initialise a base connect-src directive -#} {#- Initialise a base connect-src directive -#}
{%- set connect_src = "connect-src 'self'" -%} {%- set connect_src = "connect-src 'self'" -%}
{# Base logic for appending analytics domains #} {# Base logic for appending analytics domains #}
{%- if config.extra.goatcounter %} {%- if config.extra.goatcounter %}
{%- set goatcounter_host = config.extra.goatcounter.host | default(value='goatcounter.com') -%} {%- set goatcounter_host = config.extra.goatcounter.host | default(value='goatcounter.com') -%}
{%- set goatcounter_url = "https://" ~ config.extra.goatcounter.user ~ "." ~ goatcounter_host ~ "/count" %} {%- set goatcounter_url = "https://" ~ config.extra.goatcounter.user ~ "." ~ goatcounter_host ~ "/count" %}
{%- set script_src = script_src ~ " " ~ goatcounter_url -%} {%- set script_src = script_src ~ " " ~ goatcounter_url -%}
{%- set connect_src = connect_src ~ " " ~ goatcounter_url -%} {%- set connect_src = connect_src ~ " " ~ goatcounter_url -%}
{%- endif %} {%- endif %}
{#- Append WebSocket for Zola serve mode -#} {#- Append WebSocket for Zola serve mode -#}
{%- if config.mode == "serve" -%} {%- if config.mode == "serve" -%}
{%- set connect_src = connect_src ~ " ws:" -%} {%- set connect_src = connect_src ~ " ws:" -%}
{%- endif -%} {%- endif -%}
{%- for domain in config.extra.csp -%} {%- for domain in config.extra.csp -%}
{%- if domain.directive == "connect-src" -%} {%- if domain.directive == "connect-src" -%}
{%- set configured_connect_src = domain.domains | join(sep=' ') -%} {%- set configured_connect_src = domain.domains | join(sep=' ') -%}
{%- set_global connect_src = connect_src ~ " " ~ configured_connect_src -%} {%- set_global connect_src = connect_src ~ " " ~ configured_connect_src -%}
{%- continue -%} {%- continue -%}
{%- endif -%} {%- endif -%}
{%- if domain.directive == "script-src" -%} {%- if domain.directive == "script-src" -%}
{%- set configured_script_src = domain.domains | join(sep=' ') -%} {%- set configured_script_src = domain.domains | join(sep=' ') -%}
{%- set_global script_src = script_src ~ " " ~ configured_script_src -%} {%- set_global script_src = script_src ~ " " ~ configured_script_src -%}
{%- continue -%} {%- continue -%}
{%- endif -%} {%- endif -%}
{#- Handle directives that are not connect-src -#} {#- Handle directives that are not connect-src -#}
{{ domain.directive }} {{ domain.domains | join(sep=' ') -}} {{ domain.directive }} {{ domain.domains | join(sep=' ') -}}
{%- if not loop.last -%} {%- if not loop.last -%}
; ;
{%- endif -%} {%- endif -%}
{%- endfor -%} {%- endfor -%}
{#- Insert the generated connect-src -#} {#- Insert the generated connect-src -#}
{{ ";" ~ connect_src }} {{ ";" ~ connect_src }}
{#- Insert the generated script-src -#} {#- Insert the generated script-src -#}
{{ ";" ~ script_src }} {{ ";" ~ script_src }}
{%- endif -%}"> {%- endif -%}">

View File

@ -1,7 +1,7 @@
{%- if page.extra.default_theme -%} {%- if page.extra.default_theme -%}
data-theme="{{ page.extra.default_theme }}" data-theme="{{ page.extra.default_theme }}"
{%- elif section.extra.default_theme -%} {%- elif section.extra.default_theme -%}
data-theme="{{ section.extra.default_theme }}" data-theme="{{ section.extra.default_theme }}"
{%- elif config.extra.default_theme -%} {%- elif config.extra.default_theme -%}
data-theme="{{ config.extra.default_theme }}" data-theme="{{ config.extra.default_theme }}"
{%- endif -%} {%- endif -%}

View File

@ -1,7 +1,7 @@
{%- if page.description -%} {%- if page.description -%}
{{- page.description }} {{- page.description }}
{%- elif section.description -%} {%- elif section.description -%}
{{- section.description }} {{- section.description }}
{%- else -%} {%- else -%}
{{- config.description -}} {{- config.description -}}
{%- endif -%} {%- endif -%}

View File

@ -4,25 +4,25 @@
{%- elif section.extra.favicon -%} {%- elif section.extra.favicon -%}
{{ get_url(path=section.colocated_path ~ section.extra.favicon) }} {{ get_url(path=section.colocated_path ~ section.extra.favicon) }}
{%- else -%} {%- else -%}
{{ get_url(path='favicon.png') }} {{ get_url(path='favicon.png') }}
{%- endif -%}" /> {%- endif -%}" />
<link rel="apple-touch-icon" type="image/png" sizes="180x180" href=" <link rel="apple-touch-icon" type="image/png" sizes="180x180" href="
{%- if page.extra.apple_touch_icon -%} {%- if page.extra.apple_touch_icon -%}
{{ get_url(path=page.colocated_path ~ page.extra.apple_touch_icon) }} {{ get_url(path=page.colocated_path ~ page.extra.apple_touch_icon) }}
{%- elif section.extra.apple_touch_icon -%} {%- elif section.extra.apple_touch_icon -%}
{{ get_url(path=section.colocated_path ~ section.extra.apple_touch_icon) }} {{ get_url(path=section.colocated_path ~ section.extra.apple_touch_icon) }}
{%- else -%} {%- else -%}
{{ get_url(path='apple-touch-icon.png') }} {{ get_url(path='apple-touch-icon.png') }}
{%- endif -%}" /> {%- endif -%}" />
{%- if page.extra.emoji_favicon or section.extra.emoji_favicon or config.extra.emoji_favicon %} {%- if page.extra.emoji_favicon or section.extra.emoji_favicon or config.extra.emoji_favicon %}
<link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Ctext x='-.07em' y='.89em' font-size='90'%3E <link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Ctext x='-.07em' y='.89em' font-size='90'%3E
{%- if page.extra.emoji_favicon -%} {%- if page.extra.emoji_favicon -%}
{{ page.extra.emoji_favicon | truncate(length=1, end='') }} {{ page.extra.emoji_favicon | truncate(length=1, end='') }}
{%- elif section.extra.emoji_favicon -%} {%- elif section.extra.emoji_favicon -%}
{{ section.extra.emoji_favicon | truncate(length=1, end='') }} {{ section.extra.emoji_favicon | truncate(length=1, end='') }}
{%- else -%} {%- else -%}
{{ config.extra.emoji_favicon | truncate(length=1, end='') }} {{ config.extra.emoji_favicon | truncate(length=1, end='') }}
{%- endif -%}%3C/text%3E%3C/svg%3E"> {%- endif -%}%3C/text%3E%3C/svg%3E">
{%- endif %} {%- endif %}

View File

@ -1,42 +1,42 @@
{#- Based on https://github.com/welpo/tabi/blob/7b00ed1d9dca5c529d2816c5b6679bfe600d63fc/templates/partials/language_switcher.html -#} {#- Based on https://github.com/welpo/tabi/blob/7b00ed1d9dca5c529d2816c5b6679bfe600d63fc/templates/partials/language_switcher.html -#}
<li id="language-switcher"> <li id="language-switcher">
<details class="closable"> <details class="closable">
<summary class="circle" title="{{ macros_translate::translate(key='language', default='Language', language_strings=language_strings) }}"> <summary class="circle" title="{{ macros_translate::translate(key='language', default='Language', language_strings=language_strings) }}">
<i class="icon"></i> <i class="icon"></i>
</summary> </summary>
<ul> <ul>
{%- for lcode, ldetails in config.languages -%} {%- for lcode, ldetails in config.languages -%}
{#- Skip the current language to avoid linking to the current page -#} {#- Skip the current language to avoid linking to the current page -#}
{%- if lang == lcode -%} {%- if lang == lcode -%}
{%- continue -%} {%- continue -%}
{%- endif -%} {%- endif -%}
{#- Dynamically load the language strings for each language -#} {#- Dynamically load the language strings for each language -#}
{%- set other_language_strings = load_data(path="i18n/" ~ lcode ~ ".toml", required=false) -%} {%- set other_language_strings = load_data(path="i18n/" ~ lcode ~ ".toml", required=false) -%}
{%- if not other_language_strings -%} {%- if not other_language_strings -%}
{%- set other_language_strings = load_data(path="themes/duckquill/i18n/" ~ lcode ~ ".toml", required=false) -%} {%- set other_language_strings = load_data(path="themes/duckquill/i18n/" ~ lcode ~ ".toml", required=false) -%}
{%- endif -%} {%- endif -%}
{#- Use the loaded language strings to get the language name -#} {#- Use the loaded language strings to get the language name -#}
{% set language_name = macros_translate::translate(key="language_name", default=lcode, language_strings=other_language_strings) %} {% set language_name = macros_translate::translate(key="language_name", default=lcode, language_strings=other_language_strings) %}
{#- Check if the language code matches the default language -#} {#- Check if the language code matches the default language -#}
{%- if lcode == config.default_language -%} {%- if lcode == config.default_language -%}
{#- If it does, link to the root path (no language code in URL) -#} {#- If it does, link to the root path (no language code in URL) -#}
<li> <li>
<a lang="{{ lcode }}" href="{{ current_url | replace(from='/' ~ lang ~ '/', to = '/') }}">{{ language_name }}</a> <a lang="{{ lcode }}" href="{{ current_url | replace(from='/' ~ lang ~ '/', to = '/') }}">{{ language_name }}</a>
</li> </li>
{#- Check if the current language is the default language -#} {#- Check if the current language is the default language -#}
{#- If it is, append the language code to the base URL -#} {#- If it is, append the language code to the base URL -#}
{%- elif lang == config.default_language -%} {%- elif lang == config.default_language -%}
<li> <li>
<a lang="{{ lcode }}" href="{{ config.base_url }}/{{ lcode }}{{ current_path | default(value="/") | safe }}">{{ language_name }}</a> <a lang="{{ lcode }}" href="{{ config.base_url }}/{{ lcode }}{{ current_path | default(value="/") | safe }}">{{ language_name }}</a>
</li> </li>
{%- else -%} {%- else -%}
{#- If it's not, replace the current language code in the URL with the new one -#} {#- If it's not, replace the current language code in the URL with the new one -#}
<li> <li>
<a lang="{{ lcode }}" href="{{ current_url | replace(from='/' ~ lang ~ '/', to='/' ~ lcode ~ '/') }}">{{ language_name }}</a> <a lang="{{ lcode }}" href="{{ current_url | replace(from='/' ~ lang ~ '/', to='/' ~ lcode ~ '/') }}">{{ language_name }}</a>
</li> </li>
{%- endif -%} {%- endif -%}
{%- endfor -%} {%- endfor -%}
</ul> </ul>
</details> </details>
</li> </li>

View File

@ -1,7 +1,7 @@
{%- if page.title -%} {%- if page.title -%}
{{- page.title }} - {{ config.title -}} {{- page.title }} - {{ config.title -}}
{%- elif section.title -%} {%- elif section.title -%}
{{- section.title }} - {{ config.title -}} {{- section.title }} - {{ config.title -}}
{%- else -%} {%- else -%}
{{- config.title -}} {{- config.title -}}
{%- endif -%} {%- endif -%}

View File

@ -5,30 +5,27 @@
{%- set language_strings = load_data(path="themes/duckquill/i18n/" ~ lang ~ ".toml", required=false) -%} {%- set language_strings = load_data(path="themes/duckquill/i18n/" ~ lang ~ ".toml", required=false) -%}
{%- endif -%} {%- endif -%}
<blockquote class=" {%- if note -%}
{% if note %}note{% endif %} {%- set alert_type = "note" -%}
{% if tip %}tip{% endif %} {%- set alert_string = macros_translate::translate(key="note", default="Note", language_strings=language_strings) -%}
{% if important %}important{% endif %} {%- elif tip -%}
{% if warning %}warning{% endif %} {%- set alert_type = "tip" -%}
{% if caution %}caution{% endif %} {%- set alert_string = macros_translate::translate(key="tip", default="Tip", language_strings=language_strings) -%}
"> {%- elif important -%}
{%- set alert_type = "important" -%}
{%- set alert_string = macros_translate::translate(key="important", default="Important", language_strings=language_strings) -%}
{%- elif warning -%}
{%- set alert_type = "warning" -%}
{%- set alert_string = macros_translate::translate(key="warning", default="Warning", language_strings=language_strings) -%}
{%- elif caution -%}
{%- set alert_type = "caution" -%}
{%- set alert_string = macros_translate::translate(key="caution", default="Caution", language_strings=language_strings) -%}
{%- endif -%}
<blockquote class="{{ alert_type }}">
<p class="alert-title"> <p class="alert-title">
<i class="icon"></i> <i class="icon"></i>
{%- if note -%} {{- alert_string -}}
{{ macros_translate::translate(key="note", default="Note", language_strings=language_strings) }}
{%- endif -%}
{%- if tip -%}
{{ macros_translate::translate(key="tip", default="Tip", language_strings=language_strings) }}
{%- endif -%}
{%- if important -%}
{{ macros_translate::translate(key="important", default="Important", language_strings=language_strings) }}
{%- endif -%}
{%- if warning -%}
{{ macros_translate::translate(key="warning", default="Warning", language_strings=language_strings) }}
{%- endif -%}
{%- if caution -%}
{{ macros_translate::translate(key="caution", default="Caution", language_strings=language_strings) }}
{%- endif -%}
</p> </p>
{{ body | markdown | safe }} {{ body | markdown | safe }}
</blockquote> </blockquote>

View File

@ -1,35 +1,38 @@
{%- set image_classes = [] -%}
{%- if full -%}
{%- set image_classes = image_classes | concat(with="full") -%}
{%- endif -%}
{%- if full_bleed -%}
{%- set image_classes = image_classes | concat(with="full-bleed") -%}
{%- endif -%}
{%- if start -%}
{%- set image_classes = image_classes | concat(with="start") -%}
{%- endif -%}
{%- if end -%}
{%- set image_classes = image_classes | concat(with="end") -%}
{%- endif -%}
{%- if pixels -%}
{%- set image_classes = image_classes | concat(with="pixels") -%}
{%- endif -%}
{%- if transparent -%}
{%- set image_classes = image_classes | concat(with="transparent") -%}
{%- endif -%}
{%- if no_hover -%}
{%- set image_classes = image_classes | concat(with="no-hover") -%}
{%- endif -%}
{%- if spoiler -%}
{%- set image_classes = image_classes | concat(with="spoiler") -%}
{%- endif -%}
{%- if spoiler and solid -%}
{%- set image_classes = image_classes | concat(with="solid") -%}
{%- endif -%}
{%- set image_classes = image_classes | join(sep=" ") -%}
{%- if url_min -%} {%- if url_min -%}
<a href="{{ url }}"> <a href="{{ url }}">
<img class=" <img class="{{ image_classes }}" {%- if alt -%}alt="{{ alt }}"{%- endif -%} src="{{ url_min }}" {%- if config.markdown.lazy_async_image -%}decoding="async" loading="lazy"{%- endif -%} />
{% if full %}full{% endif %}
{% if full_bleed %}full-bleed{% endif %}
{% if start %}start{% endif %}
{% if end %}end{% endif %}
{% if pixels %}pixels{% endif %}
{% if transparent %}transparent{% endif %}
{% if no_hover %}no-hover{% endif %}
{% if spoiler %}spoiler{% endif %}
{% if spoiler and solid %}solid{% endif %}
"
{%- if alt -%}alt="{{ alt }}"{%- endif -%}
src="{{ url_min }}"
{%- if config.markdown.lazy_async_image -%}decoding="async" loading="lazy"{%- endif -%}
/>
</a> </a>
{%- else -%} {%- else -%}
<img class=" <img class="{{ image_classes }}" {%- if alt -%}alt="{{ alt }}"{%- endif -%} src="{{ url }}" {%- if config.markdown.lazy_async_image -%}decoding="async" loading="lazy"{%- endif -%} />
{% if full %}full{% endif %}
{% if full_bleed %}full-bleed{% endif %}
{% if start %}start{% endif %}
{% if end %}end{% endif %}
{% if pixels %}pixels{% endif %}
{% if transparent %}transparent{% endif %}
{% if no_hover %}no-hover{% endif %}
{% if spoiler %}spoiler{% endif %}
{% if spoiler and solid %}solid{% endif %}
"
{%- if alt -%}alt="{{ alt }}"{%- endif -%}
src="{{ url }}"
{%- if config.markdown.lazy_async_image -%}decoding="async" loading="lazy"{%- endif -%}
/>
{%- endif -%} {%- endif -%}

View File

@ -0,0 +1,16 @@
{%- if host -%}
{%- set host = host -%}
{%- else -%}
{%- set host = config.extra.comments.host -%}
{%- endif -%}
{%- if user -%}
{%- set user = user -%}
{%- else -%}
{%- set user = config.extra.comments.user -%}
{%- endif -%}
<iframe
class="mastodon-embed"
src="https://{{ host }}/@{{ user }}/{{ id }}/embed">
</iframe>

View File

@ -1,12 +1,50 @@
<video class=" {# Video classes #}
{% if full %}full{% endif %} {%- set video_classes = [] -%}
{% if full_bleed %}full-bleed{% endif %} {%- if full -%}
{% if start %}start{% endif %} {%- set video_classes = video_classes | concat(with="full") -%}
{% if end %}end{% endif %} {%- endif -%}
{% if pixels %}pixels{% endif %} {%- if full_bleed -%}
{% if transparent %}transparent{% endif %} {%- set video_classes = video_classes | concat(with="full-bleed") -%}
{% if spoiler %}spoiler{% endif %} {%- endif -%}
{% if spoiler and solid %}solid{% endif %} {%- if start -%}
" {%- set video_classes = video_classes | concat(with="start") -%}
{%- if alt -%}aria-title="{{ alt }}"{%- endif -%} {%- endif -%}
controls src="{{ url }}"></video> {%- if end -%}
{%- set video_classes = video_classes | concat(with="end") -%}
{%- endif -%}
{%- if pixels -%}
{%- set video_classes = video_classes | concat(with="pixels") -%}
{%- endif -%}
{%- if transparent -%}
{%- set video_classes = video_classes | concat(with="transparent") -%}
{%- endif -%}
{%- if spoiler -%}
{%- set video_classes = video_classes | concat(with="spoiler") -%}
{%- endif -%}
{%- if spoiler and solid -%}
{%- set video_classes = video_classes | concat(with="solid") -%}
{%- endif -%}
{%- set video_classes = video_classes | join(sep=" ") -%}
{# Video attributes #}
{%- set video_attributes = [] -%}
{%- if autoplay -%}
{%- set video_attributes = video_attributes | concat(with="autoplay") -%}
{%- endif -%}
{%- if controls -%}
{%- set video_attributes = video_attributes | concat(with="controls") -%}
{%- endif -%}
{%- if loop -%}
{%- set video_attributes = video_attributes | concat(with="loop") -%}
{%- endif -%}
{%- if muted -%}
{%- set video_attributes = video_attributes | concat(with="muted") -%}
{%- endif -%}
{%- if playsinline -%}
{%- set video_attributes = video_attributes | concat(with="playsinline") -%}
{%- endif -%}
{%- set video_attributes = video_attributes | join(sep=" ") -%}
<video class="{{ video_classes }}" src="{{ url }}" {%- if alt -%}aria-title="{{ alt }}"{%- endif -%} {{ video_attributes }}></video>

View File

@ -1,4 +1,6 @@
<iframe class="vimeo-embed" <iframe
class="vimeo-embed"
src="https://player.vimeo.com/video/{{ id }}{% if autoplay %}?autoplay=1{% endif %}" src="https://player.vimeo.com/video/{{ id }}{% if autoplay %}?autoplay=1{% endif %}"
allow="autoplay; fullscreen; picture-in-picture" allow="autoplay; fullscreen; picture-in-picture"
allowfullscreen></iframe> allowfullscreen>
</iframe>

View File

@ -1,5 +1,6 @@
<iframe class="youtube-embed" <iframe
class="youtube-embed"
src="https://www.youtube-nocookie.com/embed/{{ id }}{% if autoplay %}?autoplay=1{% endif %}{% if autoplay and start %}&start={{ start }}{% elif start %}?start={{ start }}{% endif %}" src="https://www.youtube-nocookie.com/embed/{{ id }}{% if autoplay %}?autoplay=1{% endif %}{% if autoplay and start %}&start={{ start }}{% elif start %}?start={{ start }}{% endif %}"
title="YouTube video player"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe> referrerpolicy="strict-origin-when-cross-origin" allowfullscreen>
</iframe>