From 9d208b7bd111202419e427ae7a24177372764a43 Mon Sep 17 00:00:00 2001 From: st1020 Date: Sun, 20 Jul 2025 17:06:03 +0800 Subject: [PATCH] feat: add inline_svg shortcode --- templates/shortcodes/inline_svg.html | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/templates/shortcodes/inline_svg.html b/templates/shortcodes/inline_svg.html index b26be55..2a64ea9 100644 --- a/templates/shortcodes/inline_svg.html +++ b/templates/shortcodes/inline_svg.html @@ -1,9 +1,16 @@ {% set img = body | trim_start_matches(pat="![") | trim_end_matches(pat=")") | split(pat="](") %} {% set alt = img | first() %} -{% set src = img | last() %} -{% set ignore_names = ["inline svg", "inline-svg", "inline_svg"] %} +{% set_global src = img | last() %} +{% set ignore_names = ["inline svg", "inline-svg", "inline_svg"] %} + +{% for asset in page.assets -%} +{% if asset is ending_with("/" ~ src) %} +{% set_global src = asset %} +{% endif %} +{% endfor %} +
- {{ load_data(path="@" ~ page.path ~ src) | safe}} + {{ load_data(path=src) | safe}} {% if alt and not ignore_names is containing(alt | lower) %}
{{ alt }}
{% endif %}