diff options
Diffstat (limited to 'templates/shortcodes')
| -rw-r--r-- | templates/shortcodes/audio.html | 7 | ||||
| -rw-r--r-- | templates/shortcodes/gif.html | 7 | ||||
| -rw-r--r-- | templates/shortcodes/image.html | 7 | ||||
| -rw-r--r-- | templates/shortcodes/img.html | 42 | ||||
| -rw-r--r-- | templates/shortcodes/katex.html | 1 | ||||
| -rw-r--r-- | templates/shortcodes/quote.html | 6 | ||||
| -rw-r--r-- | templates/shortcodes/video.html | 7 | ||||
| -rw-r--r-- | templates/shortcodes/vm.html | 3 | ||||
| -rw-r--r-- | templates/shortcodes/yt.html | 3 |
9 files changed, 83 insertions, 0 deletions
diff --git a/templates/shortcodes/audio.html b/templates/shortcodes/audio.html new file mode 100644 index 0000000..3f9368e --- /dev/null +++ b/templates/shortcodes/audio.html @@ -0,0 +1,7 @@ +<audio controls> + {% for source in sources -%} + {% set type = source | split(pat=".") | last -%} + <source src="{{ config.base_url | safe }}{{ page.path | safe }}{{ source | safe }}" type="{{ 'audio/' ~ type }}"> + {% endfor -%} + Your browser doesn't support the audio tag and/or the audio formats in use here – sorry! +</audio> diff --git a/templates/shortcodes/gif.html b/templates/shortcodes/gif.html new file mode 100644 index 0000000..3ae56fd --- /dev/null +++ b/templates/shortcodes/gif.html @@ -0,0 +1,7 @@ +<video autoplay loop muted playsinline> + {% for source in sources -%} + {% set type = source | split(pat=".") | last -%} + <source src="{{ config.base_url | safe }}{{ page.path | safe }}{{ source | safe }}" type="{{ 'video/' ~ type }}"> + {% endfor -%} + Your browser doesn't support the video tag, which I use in place of .gifs, and/or the video formats in use here – sorry! +</video> diff --git a/templates/shortcodes/image.html b/templates/shortcodes/image.html new file mode 100644 index 0000000..ea236ef --- /dev/null +++ b/templates/shortcodes/image.html @@ -0,0 +1,7 @@ +<picture> + {% for source in sources -%} + {% set type = source | split(pat=".") | last -%} + <source srcset="{{ config.base_url | safe}}{{ page.path | safe }}{{ source | safe }}" type="{{ 'img/' ~ type }}"> + {% endfor -%} + <img src="{{ fallback_path }}" alt="{{ fallback_alt }}"/> +</picture> diff --git a/templates/shortcodes/img.html b/templates/shortcodes/img.html new file mode 100644 index 0000000..94cb9fa --- /dev/null +++ b/templates/shortcodes/img.html @@ -0,0 +1,42 @@ +{# {{ img(path="", alt="", caption="", extended_width_pct=1.3, quality=90) }} #} + +{# container_width = (pixel size, px) * (.container's max-width) #} +{% set container_width = 16 * 42 %} + +{# figure_width = container_width - (figure margin_blocks) #} +{% set figure_width = container_width - (40 * 2) %} + +{% if path is starting_with("./") %} + {% set relative_path = page.relative_path | split(pat="/") | slice(end=-1) | join(sep="/") %} + {% set img_path = path | trim_start_matches(pat="./") %} + {% set img_path = relative_path ~ "/" ~ img_path %} +{% else %} + {% set img_path = path %} +{% endif %} + +{% if path is not ending_with(".svg") %} + {% set resize = true %} + {% set image_quality = 90 %} + {% if quality %} + {% set image_quality = quality %} + {% endif %} + + {% if extended_width_pct %} + {% if extended_width_pct == -1 %} + {# adjust extended width to container width #} + {% set extended_width_pct = 0.042 %} + {% endif %} + {% set _width = config.extra.images.max_width - figure_width %} + {% set extended_width = (extended_width_pct * _width + figure_width) | round | int %} + {% if extended_width > config.extra.images.max_width %} + {% set extended_width = config.extra.images.max_width %} + {% endif %} + {% set resized_image = resize_image(path=img_path, width=extended_width, op="fit_width", quality=image_quality) %} + {% else %} + {% set resized_image = resize_image(path=img_path, width=figure_width, op="fit_width", quality=image_quality) %} + {% endif %} +{% endif %} +<figure> + <img src="{% if resize %}{{ resized_image.url }}{% else %}{{ path }}{% endif %}" {% if alt %}alt="{{alt}}"{% endif %}/> + {% if caption %}<figcaption>{{ caption | safe }}</figcaption>{% endif %} +</figure> diff --git a/templates/shortcodes/katex.html b/templates/shortcodes/katex.html new file mode 100644 index 0000000..cac8e97 --- /dev/null +++ b/templates/shortcodes/katex.html @@ -0,0 +1 @@ +<script type="math/tex{% if block %};mode=display{% endif %}">{{body}}</script> diff --git a/templates/shortcodes/quote.html b/templates/shortcodes/quote.html new file mode 100644 index 0000000..8238b71 --- /dev/null +++ b/templates/shortcodes/quote.html @@ -0,0 +1,6 @@ +<blockquote> + {{body}}<br /> + {% if author %} + -- {{ author }} + {% endif %} +</blockquote> diff --git a/templates/shortcodes/video.html b/templates/shortcodes/video.html new file mode 100644 index 0000000..a1a2f31 --- /dev/null +++ b/templates/shortcodes/video.html @@ -0,0 +1,7 @@ +<video controls> + {% for source in sources -%} + {% set type = source | split(pat=".") | last -%} + <source src="{{ config.base_url | safe }}{{ page.path | safe }}{{ source | safe }}" type="{{ 'video/' ~ type }}"> + {% endfor -%} + Your browser doesn't support the video tag and/or the video formats in use here – sorry! +</video> diff --git a/templates/shortcodes/vm.html b/templates/shortcodes/vm.html new file mode 100644 index 0000000..230e557 --- /dev/null +++ b/templates/shortcodes/vm.html @@ -0,0 +1,3 @@ +<div style="position:relative;padding-bottom:56.25%;height:0;overflow:hidden;"> + <iframe src="https://player.vimeo.com/video/{{id}}" style="position:absolute;top:0;left:0;"></iframe> +</div> diff --git a/templates/shortcodes/yt.html b/templates/shortcodes/yt.html new file mode 100644 index 0000000..7816bd8 --- /dev/null +++ b/templates/shortcodes/yt.html @@ -0,0 +1,3 @@ +<div style="position:relative;padding-bottom:56.25%;height:0;overflow:hidden;"> + <iframe src="https://www.youtube.com/embed/{{id}}{% if autoplay %}?autoplay=1{% endif %}" style="position:absolute;top:0;left:0;"></iframe> +</div> |
