feat: add gallery shortcode

This commit is contained in:
st1020 2024-02-26 20:56:08 +08:00
parent 67b58641e5
commit 25361cfd7a
18 changed files with 23 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 120 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 324 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 357 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 192 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 204 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 250 KiB

View file

@ -156,3 +156,15 @@ The `example` admonition.
{% admonition(type="quote", title="quote") %} {% admonition(type="quote", title="quote") %}
The `quote` admonition. The `quote` admonition.
{% end %} {% end %}
## Gallery
The `admonition()` shortcode is very simple html-only clickable picture gallery that displays all images from the page assets.
It's from [Zola documentation](https://www.getzola.org/documentation/content/image-processing/)
```markdown
{{/* gallery() */}}
```
{{ gallery() }}

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View file

@ -0,0 +1,11 @@
<div class="not-prose flex flex-wrap gap-2">
{% for asset in page.assets -%}<!---->
{% if asset is matching("[.](jpg|png)$") %}<!---->
{% set image = resize_image(path=asset, width=240, height=180) %}<!---->
{% set asset_name = asset | split(pat="/") | slice(start=-1) | join(sep="/") %}
<a href="{{ get_url(path=page.path ~ asset_name) }}" target="_blank">
<img class="rounded-lg" src="{{ image.url }}" />
</a>
{% endif %}<!---->
{% endfor %}
</div>