Skip to content

Commit 63ce6a9

Browse files
committed
Add image shortcode for responsive images and increase Hugo build timeout
Signed-off-by: caesarsage <destinyerhabor6@gmail.com>
1 parent e83aaaa commit 63ce6a9

2 files changed

Lines changed: 31 additions & 1 deletion

File tree

config/_default/hugo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ disqusShortname = "microcks-io"
2222
#hasCJKLanguage = true # If hasCJKLanguage true, auto-detect Chinese/Japanese/Korean Languages in the content.
2323
hasCJKLanguage = false
2424

25+
# Increase Hugo build timeout to prevent aborts during heavy image processing
26+
timeout = "300s"
27+
2528
############################# Modules ############################
2629
[module]
2730
[[module.mounts]]
@@ -61,7 +64,7 @@ home = ["HTML", "RSS", "JSON", "WebAppManifest"]
6164
# See https://github.com/disintegration/imaging
6265
# Default JPEG or WebP quality setting. Default is 75.
6366
quality = 90
64-
resampleFilter = "lanczos"
67+
resampleFilter = "Lanczos"
6568

6669
############################# Caches ###############################
6770
[caches]

layouts/shortcodes/image.html

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{{- $src := .Get "src" -}} {{- $alt := .Get "alt" | default "" -}} {{- $width :=
2+
.Get "width" -}} {{- $height := .Get "height" -}} {{- $sizes := .Get "sizes" |
3+
default "(max-width: 800px) 100vw, 800px" -}} {{- /* For real responsive images,
4+
you would generate resized versions. Here, we use the same src for all for
5+
simplicity. */ -}} {{- $srcset := printf "%s 400w, %s 800w, %s 1200w" $src $src
6+
$src -}}
7+
<img
8+
src="{{ $src }}"
9+
alt="{{ $alt }}"
10+
{{
11+
with
12+
$width
13+
}}width="{{ . }}"
14+
{{
15+
end
16+
}}
17+
{{
18+
with
19+
$height
20+
}}height="{{ . }}"
21+
{{
22+
end
23+
}}
24+
srcset="{{ $srcset }}"
25+
sizes="{{ $sizes }}"
26+
loading="lazy"
27+
/>

0 commit comments

Comments
 (0)