summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancesco <tomaselli.fr@gmail.com>2024-05-23 13:09:47 +0200
committerFrancesco <tomaselli.fr@gmail.com>2024-05-23 13:09:47 +0200
commit721a958eafc3ab5c921cb3f95ac1538c0e8964a6 (patch)
treeb7e0574be7d3baa39f9f3e2fda8b0c6cb8cdd83a
parent379c37e43ae51cc6823e00c2ce4a6d8bad241592 (diff)
Image tags for sizing
-rw-r--r--assets/css/main.css37
-rw-r--r--assets/css/vars.css5
-rw-r--r--layouts/_default/_markup/render-image.html35
3 files changed, 65 insertions, 12 deletions
diff --git a/assets/css/main.css b/assets/css/main.css
index 4c5e085..9c0ca9d 100644
--- a/assets/css/main.css
+++ b/assets/css/main.css
@@ -337,7 +337,7 @@ footer a {
content: counter(h2-counter) "." counter(h3-counter) "." counter(h4-counter) "\00a0\00a0";
}
-/* light and dark images */
+/* images */
.dark .img-light {
display: none !important;
@@ -347,6 +347,41 @@ footer a {
display: none !important;
}
+.img-small div {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+}
+
+.img-small img {
+ scale: 80%;
+}
+
+.img-full div {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+}
+
+.img-full img {
+ width: 100vw !important;
+ max-width: 100vw !important;
+}
+
+.caption-container {
+ display: flex;
+ justify-content: center;
+}
+
+figcaption {
+ color: var(--content-secondary);
+ padding-left: var(--caption-padding);
+ padding-right: var(--caption-padding);
+ font-size: var(--caption-font-size);
+ margin-top: 1rem;
+ margin-bottom: 1rem;
+}
+
/* 404 */
.not-found {
diff --git a/assets/css/vars.css b/assets/css/vars.css
index 7956909..5e4625a 100644
--- a/assets/css/vars.css
+++ b/assets/css/vars.css
@@ -3,6 +3,8 @@
--main-padding: 1.4em;
--main-padding-bottom: 3rem;
+ --caption-padding: calc(.25 * var(--main-padding));
+
/* header settings */
--header-top-gap: 2rem;
--header-bottom-gap: 2rem;
@@ -26,6 +28,7 @@
--hx-font-size: 1.3em;
--p-font-size: 1em;
--p-line-height: 1.5em;
+ --caption-font-size: .8em;
/* List indentation */
--li-indent: 1.5rem;
@@ -68,6 +71,7 @@
:root {
--main-width: 750px;
--header-top-gap: 1rem;
+ --caption-padding: calc(.25 * var(--main-padding));
}
}
@@ -75,5 +79,6 @@
:root {
--header-top-gap: 1rem;
--social-icons-bottom-margin: 0rem;
+ --caption-padding: calc(2 * var(--main-padding));
}
} \ No newline at end of file
diff --git a/layouts/_default/_markup/render-image.html b/layouts/_default/_markup/render-image.html
index 7881b48..25d893e 100644
--- a/layouts/_default/_markup/render-image.html
+++ b/layouts/_default/_markup/render-image.html
@@ -1,16 +1,29 @@
+{{/* Split URL at # */}}
{{ $url := .Destination | safeURL }}
-
-{{ $class := "" }}
{{ $file_name_array := split $url "#" }}
-{{ $file_name_len := len $file_name_array }}
-{{ $tag := index $file_name_array (sub $file_name_len 1)}}
-{{ if eq $tag "dark" }}
-{{ $class = "img-dark" }}
-{{ else if eq $tag "light" }}
-{{ $class = "img-light" }}
-{{end }}
+{{/*
+Iterate over all tags, which are in pos 1 to len array - 1,
+and build the img class string as "img-tag1 img-tag2 ..."
+*/}}
+
+{{ $classes := "" }}
+
+{{ range $idx := seq (sub (len $file_name_array) 1) }}
+{{ $tag := index $file_name_array $idx }}
+{{ $classes = printf "%s img-%s" $classes $tag}}
+{{ end }}
+
+{{/* Use the computed classes on the rendered figure */}}
+<figure class="{{ $classes }}">
+
+ <div>
+ <img loading="lazy" alt="{{ .Text }}" src=" {{ $url }}">
+ </div>
-<figure class="{{ $class }}">
- <img loading="lazy" alt="{{ .Text }}" src=" {{ $url }}">
+ {{ with .Title }}
+ <div class="caption-container">
+ <figcaption> {{ . | markdownify}} </figcaption>
+ </div>
+ {{ end }}
</figure> \ No newline at end of file