mirror of
https://github.com/nunocoracao/blowfish.git
synced 2025-01-22 22:45:42 -06:00
Merge pull request #1513 from wermos/minor-improvements
🎨 Improvements to image handling and link handling
This commit is contained in:
commit
cc9ee9d26f
4 changed files with 68 additions and 63 deletions
|
@ -18,7 +18,7 @@ In addition to all the [default Hugo shortcodes](https://gohugo.io/content-manag
|
|||
<!-- prettier-ignore-start -->
|
||||
| Parameter | Description |
|
||||
| ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `icon` | **Optional.** the icon to display on the left side.<br>**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.<br>**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.<br>Can be either hex values (`#FFFFFF`) or color names (`white`)<br>By default chosen based on the current color theme . |
|
||||
| `cardColor` | **Optional.** the color for the card background in basic CSS style.<br>Can be either hex values (`#FFFFFF`) or color names (`white`)<br>By default chosen based on the current color theme . |
|
||||
| `textColor` | **Optional.** the color for the text in basic CSS style.<br>Can be either hex values (`#FFFFFF`) or color names (`white`)<br>By default chosen based on the current color theme . |
|
||||
|
|
|
@ -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 }}
|
||||
<figure>
|
||||
<img class="my-0 rounded-md" loading="lazy" src="{{ $url.String }}" alt="{{ $altText }}" />
|
||||
{{ with $caption }}<figcaption>{{ . | markdownify }}</figcaption>{{ end }}
|
||||
</figure>
|
||||
{{ 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 }}
|
||||
<figure>
|
||||
{{ if $disableImageOptimization }}
|
||||
{{- if or $disableImageOptimization (eq .MediaType.SubType "svg")}}
|
||||
<img
|
||||
class="my-0 rounded-md"
|
||||
loading="lazy"
|
||||
src="{{ .RelPermalink }}"
|
||||
alt="{{ $altText }}"
|
||||
/>
|
||||
{{ else }}
|
||||
{{- else }}
|
||||
<img
|
||||
class="my-0 rounded-md"
|
||||
loading="lazy"
|
||||
|
@ -35,13 +35,13 @@
|
|||
src="{{ (.Resize "660x").RelPermalink }}"
|
||||
alt="{{ $altText }}"
|
||||
/>
|
||||
{{ end }}
|
||||
{{- end }}
|
||||
{{ with $caption }}<figcaption>{{ . | markdownify }}</figcaption>{{ end }}
|
||||
</figure>
|
||||
{{ else }}
|
||||
{{- else }}
|
||||
<figure>
|
||||
<img class="my-0 rounded-md" loading="lazy" src="{{ $url.String }}" alt="{{ $altText }}" />
|
||||
{{ with $caption }}<figcaption>{{ . | markdownify }}</figcaption>{{ end }}
|
||||
</figure>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
|
|
@ -1,2 +1,7 @@
|
|||
<a href="{{ .Destination | safeURL }}" {{ with .Title}} title="{{ . }}"{{ end }} {{ if or (strings.HasPrefix .Destination "http:") (strings.HasPrefix .Destination "https:") }} target="_blank"{{ end }}>
|
||||
{{ .Text | safeHTML }}</a>
|
||||
<a href="{{ .Destination | safeURL }}"
|
||||
{{- with .Title -}}
|
||||
title="{{ . }}"
|
||||
{{- end }}
|
||||
{{- if or (strings.HasPrefix .Destination "http:") (strings.HasPrefix .Destination "https:") }} target="_blank"{{ end }}>
|
||||
{{- .Text | safeHTML -}}
|
||||
</a>
|
|
@ -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 -}}
|
||||
|
||||
<figure>
|
||||
{{ with $href }}<a href="{{ . }}" {{ with $target }}target="{{ . }}"{{ end }}>{{ end }}
|
||||
{{ if findRE "^https?" $url.Scheme }}
|
||||
<img class="my-0 rounded-md {{ with $nozoom }} nozoom {{ end }}{{ with $class }} {{ . }} {{ end }}" src="{{ $url.String }}" alt="{{ $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 }}
|
||||
<img
|
||||
class="my-0 rounded-md {{ with $nozoom }} nozoom {{ end }}{{ with $class }} {{ . }} {{ end }}"
|
||||
src="{{ .RelPermalink }}"
|
||||
alt="{{ $altText }}"
|
||||
/>
|
||||
{{ else }}
|
||||
<img
|
||||
class="my-0 rounded-md {{ with $nozoom }} nozoom {{ end }}{{ with $class }} {{ . }} {{ end }}"
|
||||
srcset="
|
||||
{{ (.Resize "330x").RelPermalink }} 330w,
|
||||
{{ (.Resize "660x").RelPermalink }} 660w,
|
||||
{{ (.Resize "1024x").RelPermalink }} 1024w,
|
||||
{{ (.Resize "1320x").RelPermalink }} 2x"
|
||||
src="{{ (.Resize "660x").RelPermalink }}"
|
||||
alt="{{ $altText }}"
|
||||
/>
|
||||
{{ end }}
|
||||
{{ else }}
|
||||
<img class="my-0 rounded-md {{ with $nozoom }} nozoom {{ end }}{{ with $class }} {{ . }} {{ end }}" src="{{ $url.String }}" alt="{{ $altText }}" />
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{- with $href }}<a href="{{ . }}" {{ with $target }}target="{{ . }}"{{ end }}>{{ end -}}
|
||||
{{- if findRE "^https?" $url.Scheme }}
|
||||
<img class="my-0 rounded-md{{ with $nozoom }} nozoom{{ end }}{{ with $class }} {{ . }}{{ end }}" src="{{ $url.String }}" alt="{{ $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")}}
|
||||
<img
|
||||
class="my-0 rounded-md{{ with $nozoom }} nozoom{{ end }}{{ with $class }} {{ . }}{{ end }}"
|
||||
src="{{ .RelPermalink }}"
|
||||
alt="{{ $altText }}"
|
||||
/>
|
||||
{{- else }}
|
||||
<img
|
||||
class="my-0 rounded-md{{ with $nozoom }} nozoom{{ end }}{{ with $class }} {{ . }}{{ end }}"
|
||||
srcset="
|
||||
{{ (.Resize "330x").RelPermalink }} 330w,
|
||||
{{ (.Resize "660x").RelPermalink }} 660w,
|
||||
{{ (.Resize "1024x").RelPermalink }} 1024w,
|
||||
{{ (.Resize "1320x").RelPermalink }} 2x"
|
||||
src="{{ (.Resize "660x").RelPermalink }}"
|
||||
alt="{{ $altText }}"
|
||||
/>
|
||||
{{- end }}
|
||||
{{- else }}
|
||||
<img class="my-0 rounded-md{{ with $nozoom }} nozoom{{ end }}{{ with $class }} {{ . }}{{ end }}" src="{{ $url.String }}" alt="{{ $altText }}" />
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{ with $caption }}<figcaption>{{ . | markdownify }}</figcaption>{{ end }}
|
||||
{{ if $href }}</a>{{ end }}
|
||||
</figure>
|
||||
{{ end }}
|
||||
{{- end -}}
|
||||
|
|
Loading…
Reference in a new issue