From 4bd51a529b6a4be210f0802428b5fd868fb6bae7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20Stiki=C4=87?= Date: Sat, 20 Jul 2024 11:24:05 +0800 Subject: [PATCH] add relative path support for shortcodes --- templates/shortcodes/figure.html | 19 +++++++++++++------ templates/shortcodes/image.html | 4 ++-- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/templates/shortcodes/figure.html b/templates/shortcodes/figure.html index d841b5c..f375b16 100644 --- a/templates/shortcodes/figure.html +++ b/templates/shortcodes/figure.html @@ -1,8 +1,15 @@ {% if src %} -
- - {% if caption %} -
{{ caption | markdown() | safe }}
- {% endif %} -
+ {# If the image's URL is internal to the site... #} + {% if src is not starting_with("http") %} + {# ... then prepend the site's base URL to the image's URL. #} + {% set src = get_url(path=page.colocated_path ~ src) %} + {% endif %} +
+ + {% if caption %} +
{{ caption | markdown() | safe }}
+ {% endif %} +
{% endif %} diff --git a/templates/shortcodes/image.html b/templates/shortcodes/image.html index 7a2f044..2d69182 100644 --- a/templates/shortcodes/image.html +++ b/templates/shortcodes/image.html @@ -2,7 +2,7 @@ {# If the image's URL is internal to the site... #} {% if src is not starting_with("http") %} {# ... then prepend the site's base URL to the image's URL. #} - {% set src = config.base_url ~ src %} + {% set src = get_url(path=page.colocated_path ~ src) %} {% endif %} - + {% endif %}