link: backout #777

This commit is contained in:
Sören Weber 2024-02-22 23:12:53 +01:00
parent 3333a4133d
commit 4e5fe8d90a
No known key found for this signature in database
GPG key ID: BEC6D55545451B6D

View file

@ -17,23 +17,25 @@
{{- $width := "auto" }} {{- $width := "auto" }}
{{- $dest_url := urls.Parse $url }} {{- $dest_url := urls.Parse $url }}
{{- $dest_path := $dest_url.Path }} {{- $dest_path := $dest_url.Path }}
{{- $image := "" }} {{- $image := $page.Resources.GetMatch (path.Clean $dest_url.Path) }}
{{- if not $dest_url.IsAbs }} {{- if not $image }}
{{- with or ($page.Resources.Get $dest_url.Path) (resources.Get $dest_url.Path) }} {{- $image = .Resources.GetMatch $dest_path }}
{{- $image = . }} {{- end }}
{{- end }} {{- if not $image }}
{{- with $image }} {{- $image = .Resources.GetRemote $url }}
{{- end }}
{{- if $image }}
{{- $url = $image.RelPermalink }} {{- $url = $image.RelPermalink }}
{{- with $dest_url.RawQuery }} {{- if $dest_url.RawQuery }}
{{- $url = printf "%s?%s" $url . }} {{- $url = printf "%s?%s" $url $dest_url.RawQuery }}
{{- end }} {{- end }}
{{- else }} {{- end }}
{{- if and (not $image) (not $dest_url.IsAbs) }}
{{- if eq $page.Site.Params.image.errorlevel "warning" }} {{- if eq $page.Site.Params.image.errorlevel "warning" }}
{{- warnf "%q: image '%s' is not a resource but linked anyways" $page.File.Filename .url }} {{- warnf "%q: image '%s' is not a resource but linked anyways" $page.File.Filename .url }}
{{- else if eq $page.Site.Params.image.errorlevel "error" }} {{- else if eq $page.Site.Params.image.errorlevel "error" }}
{{- errorf "%q: image '%s' is not a resource" $page.File.Filename .url }} {{- errorf "%q: image '%s' is not a resource" $page.File.Filename .url }}
{{- end }} {{- end }}
{{- end }}
{{- end }} {{- end }}
{{- if $dest_url.RawQuery }} {{- if $dest_url.RawQuery }}
{{- if $dest_url.Query.Has "classes" }} {{- if $dest_url.Query.Has "classes" }}