summaryrefslogtreecommitdiff
path: root/templates
diff options
context:
space:
mode:
authorMole Shang <135e2@135e2.dev>2026-02-09 23:19:16 +0800
committerMole Shang <135e2@135e2.dev>2026-02-09 23:19:16 +0800
commita582b6ef76bfb79744716f5cdfafff8c41861ec9 (patch)
tree8d73094eb53507b09ed91f14b22df75ddbd85dab /templates
parent119356da0f77ec711e694811ab5e3bc82e762624 (diff)
downloadSeje2-a582b6ef76bfb79744716f5cdfafff8c41861ec9.tar.gz
Seje2-a582b6ef76bfb79744716f5cdfafff8c41861ec9.tar.bz2
Seje2-a582b6ef76bfb79744716f5cdfafff8c41861ec9.zip
templates/page: support img caption displaymain
Diffstat (limited to 'templates')
-rw-r--r--templates/page.html24
1 files changed, 24 insertions, 0 deletions
diff --git a/templates/page.html b/templates/page.html
index ec3116d..f795876 100644
--- a/templates/page.html
+++ b/templates/page.html
@@ -50,4 +50,28 @@
{% endif %}
{% endblock %}
</div>
+
+{% if page.extra.enable_img_caption %}
+<script>
+ const images = document.querySelectorAll(".post-content img");
+ images.forEach((img) => {
+ if (img.alt && img.alt.trim() !== "") {
+ const caption = document.createElement("div");
+ caption.className = "img-caption";
+ caption.textContent = img.alt;
+
+ let insertionPoint = img;
+ if (img.parentElement.tagName === "A") {
+ insertionPoint = img.parentElement;
+ }
+
+ insertionPoint.parentNode.insertBefore(
+ caption,
+ insertionPoint.nextSibling,
+ );
+ }
+ });
+</script>
+{% endif %}
+
{% endblock %}