mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-30 22:39:58 +02:00
@@ -0,0 +1,15 @@
|
||||
{{- $u := urls.Parse .Destination -}}
|
||||
{{- $src := $u.String -}}
|
||||
{{- if not $u.IsAbs -}}
|
||||
{{- with or (.Page.Resources.Get $u.Path) (resources.Get $u.Path) -}}
|
||||
{{- $src = .RelPermalink -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- $attributes := dict "alt" .Text "src" $src "title" .Title -}}
|
||||
<img
|
||||
{{- range $k, $v := $attributes -}}
|
||||
{{- if $v -}}
|
||||
{{- printf " %s=%q" $k $v | safeHTMLAttr -}}
|
||||
{{- end -}}
|
||||
{{- end -}}>
|
||||
{{- /**/ -}}
|
@@ -0,0 +1,26 @@
|
||||
{{- $u := urls.Parse .Destination -}}
|
||||
{{- $href := $u.String -}}
|
||||
{{- if not $u.IsAbs -}}
|
||||
{{- with or
|
||||
($.Page.GetPage $u.Path)
|
||||
($.Page.Resources.Get $u.Path)
|
||||
(resources.Get $u.Path)
|
||||
-}}
|
||||
{{- $href = .RelPermalink -}}
|
||||
{{- with $u.RawQuery -}}
|
||||
{{- $href = printf "%s?%s" $href . -}}
|
||||
{{- end -}}
|
||||
{{- with $u.Fragment -}}
|
||||
{{- $href = printf "%s#%s" $href . -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- $attributes := dict "href" $href "title" .Title -}}
|
||||
<a
|
||||
{{- range $k, $v := $attributes -}}
|
||||
{{- if $v -}}
|
||||
{{- printf " %s=%q" $k $v | safeHTMLAttr -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
>{{ .Text | safeHTML }}</a>
|
||||
{{- /**/ -}}
|
Reference in New Issue
Block a user