From c54b7daff2713fbf1b78972ddda85bb15d6a745b Mon Sep 17 00:00:00 2001 From: wermos <63574588+wermos@users.noreply.github.com> Date: Sun, 2 Jun 2024 12:17:47 +0530 Subject: [PATCH 1/6] Updated the link shortcode. --- layouts/_default/_markup/render-link.html | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/layouts/_default/_markup/render-link.html b/layouts/_default/_markup/render-link.html index 83361695..9dad725a 100644 --- a/layouts/_default/_markup/render-link.html +++ b/layouts/_default/_markup/render-link.html @@ -1,2 +1 @@ - - {{ .Text | safeHTML }} \ No newline at end of file +{{ .Text | safeHTML }} \ No newline at end of file From 46737b193f3e8854a86a19f144a65807ff642871 Mon Sep 17 00:00:00 2001 From: wermos <63574588+wermos@users.noreply.github.com> Date: Mon, 3 Jun 2024 20:27:19 +0530 Subject: [PATCH 2/6] Tweaked the image shortcode. --- layouts/_default/_markup/render-image.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/layouts/_default/_markup/render-image.html b/layouts/_default/_markup/render-image.html index db9ebd2f..55001f32 100644 --- a/layouts/_default/_markup/render-image.html +++ b/layouts/_default/_markup/render-image.html @@ -16,7 +16,7 @@ {{ end }} {{ with $resource }}
- {{ if $disableImageOptimization }} + {{ if or $disableImageOptimization (eq .MediaType.SubType "svg") }} Date: Mon, 3 Jun 2024 20:39:10 +0530 Subject: [PATCH 3/6] Made the link shortcode more readable. --- layouts/_default/_markup/render-link.html | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/layouts/_default/_markup/render-link.html b/layouts/_default/_markup/render-link.html index 9dad725a..c5e9304a 100644 --- a/layouts/_default/_markup/render-link.html +++ b/layouts/_default/_markup/render-link.html @@ -1 +1,7 @@ -{{ .Text | safeHTML }} \ No newline at end of file + + {{- .Text | safeHTML -}} + \ No newline at end of file From de1cdd431c19528a80b0323e23fe8cfda52b3477 Mon Sep 17 00:00:00 2001 From: wermos <63574588+wermos@users.noreply.github.com> Date: Mon, 3 Jun 2024 20:50:15 +0530 Subject: [PATCH 4/6] Fixed an inconsistency. --- exampleSite/content/docs/shortcodes/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exampleSite/content/docs/shortcodes/index.md b/exampleSite/content/docs/shortcodes/index.md index 14ab2b35..b7ba4f5b 100644 --- a/exampleSite/content/docs/shortcodes/index.md +++ b/exampleSite/content/docs/shortcodes/index.md @@ -18,7 +18,7 @@ In addition to all the [default Hugo shortcodes](https://gohugo.io/content-manag | Parameter | Description | | ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `icon` | **Optional.** the icon to display on the left side.
**Default:** `exclaimation triangle icon` (Check out the [icon shortcode](#icon) for more details on using icons.) | +| `icon` | **Optional.** the icon to display on the left side.
**Default:** `triangle-exclamation` (Check out the [icon shortcode](#icon) for more details on using icons.) | | `iconColor` | **Optional.** the color for the icon in basic CSS style.
Can be either hex values (`#FFFFFF`) or color names (`white`)
By default chosen based on the current color theme . | | `cardColor` | **Optional.** the color for the card background in basic CSS style.
Can be either hex values (`#FFFFFF`) or color names (`white`)
By default chosen based on the current color theme . | | `textColor` | **Optional.** the color for the text in basic CSS style.
Can be either hex values (`#FFFFFF`) or color names (`white`)
By default chosen based on the current color theme . | From bb435aded72566ff3c196614cdccec187034fdc3 Mon Sep 17 00:00:00 2001 From: wermos <63574588+wermos@users.noreply.github.com> Date: Mon, 3 Jun 2024 22:34:24 +0530 Subject: [PATCH 5/6] Minified the shortcodes and added handling for SVGs. --- layouts/_default/_markup/render-image.html | 38 +++++----- layouts/shortcodes/figure.html | 86 +++++++++++----------- 2 files changed, 62 insertions(+), 62 deletions(-) diff --git a/layouts/_default/_markup/render-image.html b/layouts/_default/_markup/render-image.html index 55001f32..3e5fdce8 100644 --- a/layouts/_default/_markup/render-image.html +++ b/layouts/_default/_markup/render-image.html @@ -1,29 +1,29 @@ -{{ $disableImageOptimization := .Page.Site.Params.disableImageOptimization | default false }} -{{ $url := urls.Parse .Destination }} -{{ $altText := .Text }} -{{ $caption := .Title }} -{{ if findRE "^https?" $url.Scheme }} +{{- $disableImageOptimization := .Page.Site.Params.disableImageOptimization | default false }} +{{- $url := urls.Parse .Destination }} +{{- $altText := .Text }} +{{- $caption := .Title }} +{{- if findRE "^https?" $url.Scheme }}
{{ $altText }} {{ with $caption }}
{{ . | markdownify }}
{{ end }}
-{{ else }} - {{ $resource := "" }} - {{ if $.Page.Resources.GetMatch ($url.String) }} - {{ $resource = $.Page.Resources.GetMatch ($url.String) }} - {{ else if resources.GetMatch ($url.String) }} - {{ $resource = resources.Get ($url.String) }} - {{ end }} - {{ with $resource }} +{{- else }} + {{- $resource := "" }} + {{- if $.Page.Resources.GetMatch ($url.String) }} + {{- $resource = $.Page.Resources.GetMatch ($url.String) }} + {{- else if resources.GetMatch ($url.String) }} + {{- $resource = resources.Get ($url.String) }} + {{- end }} + {{- with $resource }}
- {{ if or $disableImageOptimization (eq .MediaType.SubType "svg") }} + {{- if or $disableImageOptimization (eq .MediaType.SubType "svg")}} {{ $altText }} - {{ else }} + {{- else }} {{ $altText }} - {{ end }} + {{- end }} {{ with $caption }}
{{ . | markdownify }}
{{ end }}
- {{ else }} + {{- else }}
{{ $altText }} {{ with $caption }}
{{ . | markdownify }}
{{ end }}
- {{ end }} -{{ end }} + {{- end }} +{{- end }} diff --git a/layouts/shortcodes/figure.html b/layouts/shortcodes/figure.html index cd881a31..2d951d63 100644 --- a/layouts/shortcodes/figure.html +++ b/layouts/shortcodes/figure.html @@ -2,49 +2,49 @@ {{ if .Get "default" }} {{ template "_internal/shortcodes/figure.html" . }} {{ else }} - {{ $url := urls.Parse (.Get "src") }} - {{ $altText := .Get "alt" }} - {{ $caption := .Get "caption" }} - {{ $href := .Get "href" }} - {{ $class := .Get "class" }} - {{ $target := .Get "target" | default "_blank" }} - {{ $nozoom := .Get "nozoom" | default false }} + {{- $url := urls.Parse (.Get "src") }} + {{- $altText := .Get "alt" }} + {{- $caption := .Get "caption" }} + {{- $href := .Get "href" }} + {{- $class := .Get "class" }} + {{- $target := .Get "target" | default "_blank" }} + {{- $nozoom := .Get "nozoom" | default false -}}
- {{ with $href }}{{ end }} - {{ if findRE "^https?" $url.Scheme }} - {{ $altText }} - {{ else }} - {{ $resource := "" }} - {{ if $.Page.Resources.GetMatch ($url.String) }} - {{ $resource = $.Page.Resources.GetMatch ($url.String) }} - {{ else if resources.GetMatch ($url.String) }} - {{ $resource = resources.Get ($url.String) }} - {{ end }} - {{ with $resource }} - {{ if $disableImageOptimization }} - {{ $altText }} - {{ else }} - {{ $altText }} - {{ end }} - {{ else }} - {{ $altText }} - {{ end }} - {{ end }} - {{ with $caption }}
{{ . | markdownify }}
{{ end }} - {{ if $href }}
{{ end }} + {{- with $href }}{{ end -}} + {{- if findRE "^https?" $url.Scheme }} + {{ $altText }} + {{- else }} + {{- $resource := "" }} + {{- if $.Page.Resources.GetMatch ($url.String) }} + {{- $resource = $.Page.Resources.GetMatch ($url.String) }} + {{- else if resources.GetMatch ($url.String) }} + {{- $resource = resources.Get ($url.String) }} + {{- end }} + {{- with $resource }} + {{- if or $disableImageOptimization (eq .MediaType.SubType "svg")}} + {{ $altText }} + {{- else }} + {{ $altText }} + {{- end }} + {{- else }} + {{ $altText }} + {{- end }} + {{- end }} + {{- with $caption }}
{{ . | markdownify }}
{{ end }} + {{- if $href }}
{{ end }}
-{{ end }} +{{- end -}} From 581aba335914034a137892257ba9bbf798d700b1 Mon Sep 17 00:00:00 2001 From: wermos <63574588+wermos@users.noreply.github.com> Date: Mon, 3 Jun 2024 22:45:22 +0530 Subject: [PATCH 6/6] Be less aggressive in removing newlines. --- layouts/_default/_markup/render-link.html | 2 +- layouts/shortcodes/figure.html | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/layouts/_default/_markup/render-link.html b/layouts/_default/_markup/render-link.html index c5e9304a..b6028bf5 100644 --- a/layouts/_default/_markup/render-link.html +++ b/layouts/_default/_markup/render-link.html @@ -2,6 +2,6 @@ {{- with .Title -}} title="{{ . }}" {{- end }} - {{- if or (strings.HasPrefix .Destination "http:") (strings.HasPrefix .Destination "https:") }} target="_blank"{{ end -}}> + {{- if or (strings.HasPrefix .Destination "http:") (strings.HasPrefix .Destination "https:") }} target="_blank"{{ end }}> {{- .Text | safeHTML -}} \ No newline at end of file diff --git a/layouts/shortcodes/figure.html b/layouts/shortcodes/figure.html index 2d951d63..fb7293c8 100644 --- a/layouts/shortcodes/figure.html +++ b/layouts/shortcodes/figure.html @@ -44,7 +44,7 @@ {{ $altText }} {{- end }} {{- end }} - {{- with $caption }}
{{ . | markdownify }}
{{ end }} - {{- if $href }}{{ end }} + {{ with $caption }}
{{ . | markdownify }}
{{ end }} + {{ if $href }}{{ end }}
{{- end -}}