Compare commits

...

15 Commits

Author SHA1 Message Date
Mark Dumay
92dc97d325 Merge pull request #1056 from gethinode/develop
Add anchor support to cards
2024-07-29 17:33:12 +02:00
Mark Dumay
2394f148e5 Merge branch 'main' into develop 2024-07-29 17:11:42 +02:00
Mark Dumay
8d259a3e3a Add anchor support to cards 2024-07-29 17:10:32 +02:00
Mark Dumay
1c8912e92e Merge pull request #1055 from gethinode/develop
Support image crop box placement
2024-07-29 11:05:05 +02:00
Mark Dumay
207c08431f Merge branch 'main' into develop 2024-07-29 08:33:16 +02:00
Mark Dumay
d2703d4885 Support image crop box placement 2024-07-29 08:32:37 +02:00
Mark Dumay
4728191370 Merge pull request #1054 from gethinode/develop
Adjust card title size on small screens
2024-07-28 08:16:23 +02:00
Mark Dumay
cd40d75962 Merge branch 'main' into develop 2024-07-28 08:10:15 +02:00
Mark Dumay
2d4732d03b Adjust card title size on small screens 2024-07-28 08:09:35 +02:00
Mark Dumay
e3c256b41f Merge pull request #1053 from gethinode/develop
Fix priority of card's thumbnail and icon args
2024-07-28 08:07:35 +02:00
Mark Dumay
f0a53f252c Merge branch 'main' into develop 2024-07-27 14:35:48 +02:00
Mark Dumay
a1273d99d5 Fix priority of card's thumbnail and icon args 2024-07-27 14:35:17 +02:00
Mark Dumay
4e62956c82 Merge pull request #1052 from gethinode/develop
Fix layout of scrollable card group
2024-07-27 14:32:52 +02:00
Mark Dumay
cf096a7f6a Merge branch 'main' into develop 2024-07-27 14:13:47 +02:00
Mark Dumay
ee790dc6fd Fix layout of scrollable card group 2024-07-27 14:13:20 +02:00
19 changed files with 161 additions and 19 deletions

View File

@@ -271,6 +271,25 @@ arguments:
One or more strings separated by commas, indicating the source sizes of an One or more strings separated by commas, indicating the source sizes of an
image set. image set.
group: partial group: partial
anchor:
type: select
optional: true
comment:
Anchor of the thumbnail's crop box, defaults to anchor value set in
`imaging` section of the site configuration (usually `Smart`).
options:
values:
- TopLeft
- Top
- TopRight
- Left
- Center
- Right
- BottomLeft
- Bottom
- BottomRight
- Smart
release: v0.24.23
body: body:
optional: true optional: true
comment: >- comment: >-

View File

@@ -60,3 +60,20 @@ arguments:
type: int type: int
optional: false optional: false
comment: Width of the image in pixels. comment: Width of the image in pixels.
anchor:
type: select
optional: true
comment: Anchor of the crop box.
options:
values:
- TopLeft
- Top
- TopRight
- Left
- Center
- Right
- BottomLeft
- Bottom
- BottomRight
- Smart

View File

@@ -138,3 +138,22 @@ arguments:
Flag to indicate if the image should render a plain image instead of an Flag to indicate if the image should render a plain image instead of an
image set. When set, no transformations are applied to the image. image set. When set, no transformations are applied to the image.
release: v0.24.0 release: v0.24.0
anchor:
type: select
optional: true
comment:
Anchor of the crop box, defaults to anchor value set in `imaging` section
of the site configuration (usually `Smart`).
options:
values:
- TopLeft
- Top
- TopRight
- Left
- Center
- Right
- BottomLeft
- Bottom
- BottomRight
- Smart
release: v0.24.22

View File

@@ -26,7 +26,7 @@ As an example, the following shortcode displays an image with rounded corners an
<!-- markdownlint-disable MD037 --> <!-- markdownlint-disable MD037 -->
{{< example lang="hugo" >}} {{< example lang="hugo" >}}
{{</* image src="https://ik.imagekit.io/demo/default-image.jpg" {{</* image src="https://ik.imagekit.io/demo/default-image.jpg"
ratio="21x9" caption="ImageKit.io image" class="rounded" */>}} ratio="21x9" caption="ImageKit.io image" class="rounded" anchor="Center" */>}}
{{< /example >}} {{< /example >}}
<!-- markdownlint-enable MD037 --> <!-- markdownlint-enable MD037 -->
@@ -37,6 +37,6 @@ As an example, the following shortcode displays an image with rounded corners an
<!-- markdownlint-disable MD037 --> <!-- markdownlint-disable MD037 -->
{{< example lang="hugo" >}} {{< example lang="hugo" >}}
{{</* image src="https://assets.imgix.net/examples/bluehat.jpg" {{</* image src="https://assets.imgix.net/examples/bluehat.jpg"
ratio="21x9" caption="imgix image" class="rounded" */>}} ratio="21x9" caption="imgix image" class="rounded" anchor="Top" */>}}
{{< /example >}} {{< /example >}}
<!-- markdownlint-enable MD037 --> <!-- markdownlint-enable MD037 -->

View File

@@ -239,6 +239,7 @@
"fs-3", "fs-3",
"fs-5", "fs-5",
"fs-6", "fs-6",
"fs-lg-5",
"fs-md-5", "fs-md-5",
"fw-30", "fw-30",
"fw-bold", "fw-bold",

View File

@@ -6,6 +6,19 @@
{{ $error := false }} {{ $error := false }}
{{ $anchorMap := dict
"TopLeft" "north_west"
"Top" "north"
"TopRight" "north_east"
"Left" "west"
"Center" "center"
"Right" "east"
"BottomLeft" "south_west"
"Bottom" "south"
"BottomRight" "south_east"
"Smart" "auto"
}}
<!-- Validate arguments --> <!-- Validate arguments -->
{{ if partial "utilities/IsInvalidArgs.html" (dict "structure" "image-adapter" "args" . "group" "partial") }} {{ if partial "utilities/IsInvalidArgs.html" (dict "structure" "image-adapter" "args" . "group" "partial") }}
{{ errorf "partial [assets/adapter/cloudinary.html] - Invalid arguments" -}} {{ errorf "partial [assets/adapter/cloudinary.html] - Invalid arguments" -}}
@@ -20,6 +33,8 @@
{{ $transform := .transform }} {{ $transform := .transform }}
{{ $height := .height }} {{ $height := .height }}
{{ $width := .width }} {{ $width := .width }}
{{ $anchor := "" }}
{{ with .anchor }}{{ $anchor = index $anchorMap . }}{{ end }}
{{ if eq $transform "fill" }}{{ $transform = "c_fill" }}{{ else }}{{ $transform = "c_fit" }}{{ end }} {{ if eq $transform "fill" }}{{ $transform = "c_fill" }}{{ else }}{{ $transform = "c_fit" }}{{ end }}
{{ $element := "" }} {{ $element := "" }}
@@ -37,6 +52,9 @@
{{ else }} {{ else }}
{{ $operation = printf "f_auto,%s,h_%d,w_%d" $transform $height $width }} {{ $operation = printf "f_auto,%s,h_%d,w_%d" $transform $height $width }}
{{ end }} {{ end }}
{{ with $anchor }}
{{ $operation = printf "%s,g_%s" $operation . }}
{{ end }}
{{- $element = urls.JoinPath (slice "https://" $host $dir $operation $file) -}} {{- $element = urls.JoinPath (slice "https://" $host $dir $operation $file) -}}
{{ end }} {{ end }}

View File

@@ -20,6 +20,7 @@
{{ $transform := .transform }} {{ $transform := .transform }}
{{ $height := .height }} {{ $height := .height }}
{{ $width := .width }} {{ $width := .width }}
{{ $anchor := .anchor | default "" }}
{{ $element := "" }} {{ $element := "" }}
{{ $absoluteURL := .absoluteURL }} {{ $absoluteURL := .absoluteURL }}
{{ $url := urls.JoinPath $dir $file }} {{ $url := urls.JoinPath $dir $file }}
@@ -46,13 +47,20 @@
{{ if not $error }} {{ if not $error }}
{{ $scaled := "" }} {{ $scaled := "" }}
{{ if eq $transform "fill" }} {{ if eq $transform "fill" }}
{{- $scaled = $img.Fill (printf "%dx%d %s" $width $height $format) -}} {{- $scaled = $img.Fill (printf "%dx%d %s %s" $width $height $anchor $format) -}}
{{ else }} {{ else }}
{{- $scaled = $img.Fit (printf "%dx%d %s" $width $height $format) -}} {{- $scaled = $img.Fit (printf "%dx%d %s" $width $height $format) -}}
{{ end }} {{ end }}
{{- $clean := path.Ext $img.RelPermalink -}} {{- $clean := path.Ext $img.RelPermalink -}}
{{- $scaled = $scaled | resources.Copy (replace $img.RelPermalink $clean (printf "-%dx%d.%s" $width $height $format)) -}} {{ $destination := "" }}
{{ if $anchor }}
{{ $destination = printf "-%dx%d-%s.%s" $width $height (lower $anchor) $format }}
{{ else }}
{{ $destination = printf "-%dx%d.%s" $width $height $format }}
{{ end }}
{{- $scaled = $scaled | resources.Copy (replace $img.RelPermalink $clean $destination) -}}
{{- if $absoluteURL -}} {{- if $absoluteURL -}}
{{- $element = $scaled.Permalink -}} {{- $element = $scaled.Permalink -}}
{{- else -}} {{- else -}}

View File

@@ -6,6 +6,19 @@
{{ $error := false }} {{ $error := false }}
{{ $anchorMap := dict
"TopLeft" "top_left"
"Top" "top"
"TopRight" "top_right"
"Left" "left"
"Center" "center"
"Right" "right"
"BottomLeft" "bottom_left"
"Bottom" "bottom"
"BottomRight" "bottom_right"
"Smart" "auto"
}}
<!-- Validate arguments --> <!-- Validate arguments -->
{{ if partial "utilities/IsInvalidArgs.html" (dict "structure" "image-adapter" "args" . "group" "partial") }} {{ if partial "utilities/IsInvalidArgs.html" (dict "structure" "image-adapter" "args" . "group" "partial") }}
{{ errorf "partial [assets/adapter/imagekit.html] - Invalid arguments" -}} {{ errorf "partial [assets/adapter/imagekit.html] - Invalid arguments" -}}
@@ -20,6 +33,8 @@
{{ $transform := .transform }} {{ $transform := .transform }}
{{ $height := .height }} {{ $height := .height }}
{{ $width := .width }} {{ $width := .width }}
{{ $anchor := "" }}
{{ with .anchor }}{{ $anchor = index $anchorMap . }}{{ end }}
{{ if eq $transform "fill" }}{{ $transform = "c-maintain_ratio" }}{{ else }}{{ $transform = "c-at_max" }}{{ end }} {{ if eq $transform "fill" }}{{ $transform = "c-maintain_ratio" }}{{ else }}{{ $transform = "c-at_max" }}{{ end }}
{{ $element := "" }} {{ $element := "" }}
@@ -42,6 +57,9 @@
{{ else }} {{ else }}
{{ $operation = printf "tr:f-auto,%s,h-%d,w-%d" $transform $height $width }} {{ $operation = printf "tr:f-auto,%s,h-%d,w-%d" $transform $height $width }}
{{ end }} {{ end }}
{{ with $anchor }}
{{ $operation = printf "%s,fo-%s" $operation . }}
{{ end }}
{{- $element = urls.JoinPath (slice "https://" $host $dir $operation $file) -}} {{- $element = urls.JoinPath (slice "https://" $host $dir $operation $file) -}}
{{ end }} {{ end }}

View File

@@ -6,6 +6,19 @@
{{ $error := false }} {{ $error := false }}
{{ $anchorMap := dict
"TopLeft" "top,left"
"Top" "top"
"TopRight" "top,right"
"Left" "left"
"Center" "center"
"Right" "right"
"BottomLeft" "bottom,left"
"Bottom" "bottom"
"BottomRight" "bottom,right"
"Smart" "faces,edges,center"
}}
<!-- Validate arguments --> <!-- Validate arguments -->
{{ if partial "utilities/IsInvalidArgs.html" (dict "structure" "image-adapter" "args" . "group" "partial") }} {{ if partial "utilities/IsInvalidArgs.html" (dict "structure" "image-adapter" "args" . "group" "partial") }}
{{ errorf "partial [assets/adapter/imgix.html] - Invalid arguments" -}} {{ errorf "partial [assets/adapter/imgix.html] - Invalid arguments" -}}
@@ -20,6 +33,8 @@
{{ $transform := .transform }} {{ $transform := .transform }}
{{ $height := .height }} {{ $height := .height }}
{{ $width := .width }} {{ $width := .width }}
{{ $anchor := "" }}
{{ with .anchor }}{{ $anchor = index $anchorMap . }}{{ end }}
{{ if eq $transform "fill" }}{{ $transform = "crop" }}{{ else }}{{ $transform = "max" }}{{ end }} {{ if eq $transform "fill" }}{{ $transform = "crop" }}{{ else }}{{ $transform = "max" }}{{ end }}
{{ $element := "" }} {{ $element := "" }}
@@ -37,6 +52,9 @@
{{ else }} {{ else }}
{{ $operation = printf "f_auto&fit=%s&h=%d&w=%d" $transform $height $width }} {{ $operation = printf "f_auto&fit=%s&h=%d&w=%d" $transform $height $width }}
{{ end }} {{ end }}
{{ with $anchor }}
{{ $operation = printf "%s&crop=%s" $operation . }}
{{ end }}
{{- $element = printf "%s?%s" (urls.JoinPath (slice "https://" $host $dir $file)) $operation -}} {{- $element = printf "%s?%s" (urls.JoinPath (slice "https://" $host $dir $file)) $operation -}}
{{ end }} {{ end }}

View File

@@ -71,11 +71,13 @@
<!-- headless page --> <!-- headless page -->
{{- else -}} {{- else -}}
{{- $thumbnail := (or (and (reflect.IsMap $element.Params.Thumbnail) $element.Params.Thumbnail.url) $element.Params.Thumbnail) -}} {{- $thumbnail := (or (and (reflect.IsMap $element.Params.Thumbnail) $element.Params.Thumbnail.url) $element.Params.Thumbnail) -}}
{{- $anchor := (or (and (reflect.IsMap $element.Params.Thumbnail) $element.Params.Thumbnail.anchor) "") -}}
{{- $params = merge $params (dict {{- $params = merge $params (dict
"title" $element.Title "title" $element.Title
"href" $element.RelPermalink "href" $element.RelPermalink
"description" (partial "utilities/GetDescription.html" (dict "page" $element "raw" true)) "description" (partial "utilities/GetDescription.html" (dict "page" $element "raw" true))
"thumbnail" $thumbnail "thumbnail" $thumbnail
"anchor" $anchor
"icon" $element.Params.icon "icon" $element.Params.icon
) -}} ) -}}
{{- end -}} {{- end -}}
@@ -127,7 +129,7 @@
{{- if and (eq $cols "1") (eq $orientation "horizontal") }}{{ $orientation = "horizontal-sm" }}{{ end -}} {{- if and (eq $cols "1") (eq $orientation "horizontal") }}{{ $orientation = "horizontal-sm" }}{{ end -}}
<!-- Main code --> <!-- Main code -->
<div class="container {{ $wrapper }} {{ if $scroll }}card-container-wrapper{{ end }}"> <div class="container-fluid {{ $wrapper }} {{ if $scroll }}card-container-wrapper{{ end }}">
<div class="row g-{{ $gutter }} {{ if $scroll }}d-flex flex-row flex-nowrap card-container scrollbar-horizontal pb-4 w-100 {{ end }} {{ $colGrid }}"> <div class="row g-{{ $gutter }} {{ if $scroll }}d-flex flex-row flex-nowrap card-container scrollbar-horizontal pb-4 w-100 {{ end }} {{ $colGrid }}">
{{ range $index, $element := $list }} {{ range $index, $element := $list }}
{{- $params := (dict {{- $params := (dict

View File

@@ -32,6 +32,7 @@
{{- $ratio := .ratio -}} {{- $ratio := .ratio -}}
{{- $portrait := .portrait | default false -}} {{- $portrait := .portrait | default false -}}
{{- $thumbnail := .thumbnail -}} {{- $thumbnail := .thumbnail -}}
{{- $anchor := .anchor | default "" -}}
{{- $title := .title -}} {{- $title := .title -}}
{{- $subtle := .subtle -}} {{- $subtle := .subtle -}}
{{- $button := .button -}} {{- $button := .button -}}
@@ -59,11 +60,12 @@
{{- if not $title }}{{ $title = .Title }}{{ end -}} {{- if not $title }}{{ $title = .Title }}{{ end -}}
{{- if not $href }}{{ $href = .RelPermalink }}{{ end -}} {{- if not $href }}{{ $href = .RelPermalink }}{{ end -}}
{{- if not $description }}{{ $description = partial "utilities/GetDescription.html" (dict "page" .) }}{{ end -}} {{- if not $description }}{{ $description = partial "utilities/GetDescription.html" (dict "page" .) }}{{ end -}}
{{- if not $thumbnail }}{{ $thumbnail = (or (and (reflect.IsMap .Params.Thumbnail) .Params.Thumbnail.url) .Params.Thumbnail) }}{{ end -}} {{- if and (not $thumbnail) (not $icon) }}{{ $thumbnail = (or (and (reflect.IsMap .Params.Thumbnail) .Params.Thumbnail.url) .Params.Thumbnail) }}{{ end -}}
{{ if not $ratio }} {{ if not $ratio }}
{{- if and (reflect.IsMap .Params.Thumbnail) .Params.Thumbnail.ratio }}{{ $ratio = .Params.Thumbnail.ratio }}{{ end -}} {{- if and (reflect.IsMap .Params.Thumbnail) .Params.Thumbnail.ratio }}{{ $ratio = .Params.Thumbnail.ratio }}{{ end -}}
{{ end }} {{ end }}
{{- if not $icon }}{{ $icon = .Params.icon }}{{ end -}} {{- if not $icon }}{{ $icon = .Params.icon }}{{ end -}}
{{- if not $anchor }}{{ $anchor = (or (and (reflect.IsMap .Params.Thumbnail) .Params.Thumbnail.anchor) "") }}{{ end -}}
{{- end -}} {{- end -}}
{{ if (hasPrefix $orientation "horizontal") }} {{ if (hasPrefix $orientation "horizontal") }}
@@ -86,7 +88,7 @@
{{- if $href -}} {{- if $href -}}
<a href="{{ $href }}" class="{{ if $color }}link-bg-{{ $color }}{{ else }}card-body-link{{ end }} stretched-link"> <a href="{{ $href }}" class="{{ if $color }}link-bg-{{ $color }}{{ else }}card-body-link{{ end }} stretched-link">
<p class="card-title fs-5 fw-bold">{{ $title }}</p> <p class="card-title fs-lg-5 fs-6 fw-bold">{{ $title }}</p>
{{ with $description }} {{ with $description }}
<div class="card-text {{ if $color }}link-bg-{{ $color }}{{ else }}card-body-link{{ end }}"> <div class="card-text {{ if $color }}link-bg-{{ $color }}{{ else }}card-body-link{{ end }}">
{{ . | safeHTML }} {{ . | safeHTML }}
@@ -95,7 +97,7 @@
</a> </a>
{{- else -}} {{- else -}}
<div> <div>
{{ with $title }}<p class="card-title fs-5 fw-bold">{{ . }}</p>{{ end -}} {{ with $title }}<p class="card-title fs-lg-5 fs-6 fw-bold">{{ . }}</p>{{ end -}}
{{ with $description }}<div class="card-text">{{ . | safeHTML }}</div>{{ end -}} {{ with $description }}<div class="card-text">{{ . | safeHTML }}</div>{{ end -}}
</div> </div>
{{- end -}} {{- end -}}
@@ -167,7 +169,7 @@
<div class="row g-0 row-cols-2 h-100{{ if $button }} pb-5{{ end }}"> <div class="row g-0 row-cols-2 h-100{{ if $button }} pb-5{{ end }}">
{{- if $thumbnail -}} {{- if $thumbnail -}}
<div class="{{ $col1 }}"> <div class="{{ $col1 }}">
{{- partial $hook (dict "url" $thumbnail "ratio" (or $ratio "1x1") "portrait" $portrait "sizes" $sizes "wrapper" "h-100 card-img-wrap" "class" "rounded-start card-img-h100 card-img-bg" "title" $title "loading" $loading) -}} {{- partial $hook (dict "url" $thumbnail "ratio" (or $ratio "1x1") "portrait" $portrait "sizes" $sizes "anchor" $anchor "wrapper" "h-100 card-img-wrap" "class" "rounded-start card-img-h100 card-img-bg" "title" $title "loading" $loading) -}}
</div> </div>
{{- else if $icon -}} {{- else if $icon -}}
<div class="{{ $col1 }} p-{{ $padding }}"> <div class="{{ $col1 }} p-{{ $padding }}">
@@ -212,7 +214,7 @@
<!-- Render stacked / default card --> <!-- Render stacked / default card -->
<div class="card {{ $colorStyle }} {{ $class }} text-{{ $align }}"> <div class="card {{ $colorStyle }} {{ $class }} text-{{ $align }}">
{{- if $thumbnail -}} {{- if $thumbnail -}}
{{- partial $hook (dict "url" $thumbnail "ratio" (or $ratio "16x9") "portrait" $portrait "sizes" $sizes "wrapper" "card-img-wrap" "class" "card-img-top card-img-bg" "title" (or $alt $title) "loading" $loading) -}} {{- partial $hook (dict "url" $thumbnail "ratio" (or $ratio "16x9") "portrait" $portrait "anchor" $anchor "sizes" $sizes "wrapper" "card-img-wrap" "class" "card-img-top card-img-bg" "title" (or $alt $title) "loading" $loading) -}}
{{- else if $icon -}} {{- else if $icon -}}
<div class="card-icon p-{{ $padding }} {{ $iconStyle }} text-{{ $align }} {{ if $iconRounded }}fa-stack {{ $stack }}{{ end }} w-100"> <div class="card-icon p-{{ $padding }} {{ $iconStyle }} text-{{ $align }} {{ if $iconRounded }}fa-stack {{ $stack }}{{ end }} w-100">
{{ if $iconRounded }} {{ if $iconRounded }}

View File

@@ -15,15 +15,16 @@
{{- $mode := .mode -}} {{- $mode := .mode -}}
{{- $modes := .modes -}} {{- $modes := .modes -}}
{{- $plain := .plain | default false }} {{- $plain := .plain | default false }}
{{- $anchor := .anchor }}
<!-- Split url into base and anchor when applicable (only relevant for vector images) --> <!-- Split url into base and anchor when applicable (only relevant for vector images) -->
{{- $anchor := "" -}} {{- $fileAnchor := "" -}}
{{- $segments := split $url "#" -}} {{- $segments := split $url "#" -}}
{{- if gt (len $segments) 2 -}} {{- if gt (len $segments) 2 -}}
{{- errorf "Invalid path or url: %q" $url -}} {{- errorf "Invalid path or url: %q" $url -}}
{{- else if eq (len $segments) 2 }} {{- else if eq (len $segments) 2 }}
{{- $url = index $segments 0 -}} {{- $url = index $segments 0 -}}
{{- $anchor = index $segments 1 -}} {{- $fileAnchor = index $segments 1 -}}
{{- end -}} {{- end -}}
<!-- Obtain fallback URL and imageset definition --> <!-- Obtain fallback URL and imageset definition -->
@@ -34,6 +35,7 @@
"portrait" $portrait "portrait" $portrait
"plain" $plain "plain" $plain
"imageset" true "imageset" true
"anchor" $anchor
) }} ) }}
{{ $fallbackURL := index $target "target" }} {{ $fallbackURL := index $target "target" }}
{{ $imgset := index $target "set" }} {{ $imgset := index $target "set" }}
@@ -53,7 +55,7 @@
{{ else }} {{ else }}
{{ with $wrapper }}<div class="{{ . }}">{{ end }} {{ with $wrapper }}<div class="{{ . }}">{{ end }}
{{ end }} {{ end }}
{{- if not $anchor -}} {{- if not $fileAnchor -}}
<img class="img-fluid {{ $class }}" <img class="img-fluid {{ $class }}"
src="{{ $fallbackURL }}" src="{{ $fallbackURL }}"
{{ if $lazy }}loading="lazy"{{ end }} {{ if $lazy }}loading="lazy"{{ end }}
@@ -64,7 +66,7 @@
{{ with (or $title $caption) }}alt="{{ . }}"{{ end }}> {{ with (or $title $caption) }}alt="{{ . }}"{{ end }}>
{{- else }} {{- else }}
<svg class="{{ $class }}"> <svg class="{{ $class }}">
<use href="{{ $fallbackURL }}#{{ $anchor }}"></use> <use href="{{ $fallbackURL }}#{{ $fileAnchor }}"></use>
</svg> </svg>
{{ end }} {{ end }}
{{- if $caption -}} {{- if $caption -}}

View File

@@ -9,6 +9,7 @@
{{- $targetURL := "" -}} {{- $targetURL := "" -}}
{{- $set := "" -}} {{- $set := "" -}}
{{- $imageset := .imageset | default false }} {{- $imageset := .imageset | default false }}
{{- $anchor := .anchor | default "" -}}
<!-- Split url into base and anchor when applicable (only relevant for vector images) --> <!-- Split url into base and anchor when applicable (only relevant for vector images) -->
{{- $segments := split $url "#" -}} {{- $segments := split $url "#" -}}
@@ -118,13 +119,21 @@
"url" $url "url" $url
"img" $img "img" $img
"dims" ($dims | last 1) "dims" ($dims | last 1)
"anchor" $anchor
"transform" $transform "transform" $transform
"hook" $hook "hook" $hook
"format" "jpg" "format" "png"
"includeWidth" false "includeWidth" false
)}} )}}
{{ if $imageset }} {{ if $imageset }}
{{- $set = partial "assets/helpers/image-set.html" (dict "url" $url "img" $img "dims" $dims "transform" $transform "hook" $hook) -}} {{- $set = partial "assets/helpers/image-set.html" (dict
"url" $url
"img" $img
"dims" $dims
"anchor" $anchor
"transform" $transform
"hook" $hook
) -}}
{{ end }} {{ end }}
{{ end }} {{ end }}

View File

@@ -7,6 +7,7 @@
{{ $transform := .transform }} {{ $transform := .transform }}
{{ $format := .format }} {{ $format := .format }}
{{ $includeWidth := .includeWidth | default true }} {{ $includeWidth := .includeWidth | default true }}
{{ $anchor := .anchor | default "" }}
{{ $host := (urls.Parse $url).Hostname }} {{ $host := (urls.Parse $url).Hostname }}
{{ $dir := (urls.Parse $url).Path }} {{ $dir := (urls.Parse $url).Path }}
@@ -35,6 +36,7 @@
"width" $width "width" $width
"height" $height "height" $height
"format" $format "format" $format
"anchor" $anchor
)}} )}}
{{ if $includeWidth }} {{ if $includeWidth }}
{{ $imgset = $imgset | append (printf "%s %dw" $element $width) }} {{ $imgset = $imgset | append (printf "%s %dw" $element $width) }}

View File

@@ -27,6 +27,7 @@
{{- if eq $priority "auto" }}{{ $priority = "" }}{{ end -}} {{- if eq $priority "auto" }}{{ $priority = "" }}{{ end -}}
{{- $sizes := .sizes | default "100vw" -}} {{- $sizes := .sizes | default "100vw" -}}
{{- $plain := .plain | default false -}} {{- $plain := .plain | default false -}}
{{- $anchor := .anchor | default "" -}}
{{- $absoluteURL := site.Params.main.canonifyAssetsURLs | default false -}} {{- $absoluteURL := site.Params.main.canonifyAssetsURLs | default false -}}
{{- $url := .url -}} {{- $url := .url -}}
@@ -49,6 +50,7 @@
"sizes" $sizes "sizes" $sizes
"absoluteURL" $absoluteURL "absoluteURL" $absoluteURL
"plain" $plain "plain" $plain
"anchor" $anchor
) )
-}} -}}

View File

@@ -32,6 +32,7 @@
{{- $page := .Page -}} {{- $page := .Page -}}
{{- $path := .Get "path" -}} {{- $path := .Get "path" -}}
{{- $thumbnail := .Get "thumbnail" -}} {{- $thumbnail := .Get "thumbnail" -}}
{{- $anchor := .Get "anchor" -}}
{{- $title := .Get "title" -}} {{- $title := .Get "title" -}}
{{- $button := partial "utilities/GetArgParent" (dict "page" . "arg" "button") | default false -}} {{- $button := partial "utilities/GetArgParent" (dict "page" . "arg" "button") | default false -}}
{{- $buttonType := partial "utilities/GetArgParent" (dict "page" . "arg" "buttonType") | default "" -}} {{- $buttonType := partial "utilities/GetArgParent" (dict "page" . "arg" "buttonType") | default "" -}}
@@ -81,6 +82,7 @@
"wrapper" $wrapper "wrapper" $wrapper
"thumbnail" $thumbnail "thumbnail" $thumbnail
"loading" $loading "loading" $loading
"anchor" $anchor
"alt" $alt "alt" $alt
"button" $button "button" $button
"buttonType" $buttonType "buttonType" $buttonType

View File

@@ -25,6 +25,7 @@
{{- $loading := "" -}} {{- $loading := "" -}}
{{- $error := false -}} {{- $error := false -}}
{{- $plain := false -}} {{- $plain := false -}}
{{- $anchor := "" -}}
{{- if .IsNamedParams -}} {{- if .IsNamedParams -}}
{{ $url = .Get "src" | default "" -}} {{ $url = .Get "src" | default "" -}}
@@ -39,6 +40,7 @@
{{ with .Get "mode" }}{{ $mode = partial "utilities/CastBool.html" . }}{{ end -}} {{ with .Get "mode" }}{{ $mode = partial "utilities/CastBool.html" . }}{{ end -}}
{{ with .Get "portrait" }}{{ $portrait = partial "utilities/CastBool.html" . }}{{ end -}} {{ with .Get "portrait" }}{{ $portrait = partial "utilities/CastBool.html" . }}{{ end -}}
{{ with .Get "plain" }}{{ $plain = partial "utilities/CastBool.html" . }}{{ end -}} {{ with .Get "plain" }}{{ $plain = partial "utilities/CastBool.html" . }}{{ end -}}
{{ $anchor = .Get "anchor" | default "" -}}
{{ else -}} {{ else -}}
{{ $url = .Get 0 }} {{ $url = .Get 0 }}
{{ end -}} {{ end -}}
@@ -61,6 +63,7 @@
"mode" $mode "mode" $mode
"portrait" $portrait "portrait" $portrait
"plain" $plain "plain" $plain
"anchor" $anchor
"loading" $loading "loading" $loading
"page" .Page) "page" .Page)
-}} -}}

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{ {
"name": "@gethinode/hinode", "name": "@gethinode/hinode",
"version": "0.24.20", "version": "0.24.23",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@gethinode/hinode", "name": "@gethinode/hinode",
"version": "0.24.20", "version": "0.24.23",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@fullhuman/postcss-purgecss": "^6.0.0", "@fullhuman/postcss-purgecss": "^6.0.0",

View File

@@ -1,6 +1,6 @@
{ {
"name": "@gethinode/hinode", "name": "@gethinode/hinode",
"version": "0.24.20", "version": "0.24.23",
"description": "Hinode is a clean documentation and blog theme for Hugo, an open-source static site generator", "description": "Hinode is a clean documentation and blog theme for Hugo, an open-source static site generator",
"keywords": [ "keywords": [
"hugo", "hugo",