Skip to content

Commit

Permalink
feat: add gallery shortcode
Browse files Browse the repository at this point in the history
  • Loading branch information
st1020 committed Feb 26, 2024
1 parent 67b5864 commit 25361cf
Show file tree
Hide file tree
Showing 18 changed files with 23 additions and 0 deletions.
Binary file added content/shortcodes/01-zola.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added content/shortcodes/02-zola-manet.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added content/shortcodes/03-zola-cezanne.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added content/shortcodes/04-gutenberg.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added content/shortcodes/05-example.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added content/shortcodes/06-example.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added content/shortcodes/07-example.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added content/shortcodes/08-example.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions content/shortcodes.md → content/shortcodes/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,3 +156,15 @@ The `example` admonition.
{% admonition(type="quote", title="quote") %}
The `quote` admonition.
{% 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() }}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions templates/shortcodes/gallery.html
Original file line number Diff line number Diff line change
@@ -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>

0 comments on commit 25361cf

Please sign in to comment.