mirror of
https://github.com/nunocoracao/blowfish.git
synced 2026-01-30 16:31:52 +01:00
feat: adopt Hugo embed render-link logic
This commit is contained in:
@@ -25,7 +25,7 @@ static
|
|||||||
#
|
#
|
||||||
# This create an unclose node
|
# This create an unclose node
|
||||||
|
|
||||||
layouts/_default/_markup/render-heading.html
|
layouts/_default/_markup
|
||||||
layouts/_default/index.json
|
layouts/_default/index.json
|
||||||
layouts/shortcodes/screenshot.html
|
layouts/shortcodes/screenshot.html
|
||||||
layouts/shortcodes/figure.html
|
layouts/shortcodes/figure.html
|
||||||
|
|||||||
@@ -1,11 +1,30 @@
|
|||||||
<a
|
{{/* From Hugo, Apache v2 license
|
||||||
href="{{ .Destination | safeURL }}"
|
https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/_markup/render-link.html
|
||||||
{{- with .Title -}}
|
*/}}
|
||||||
title="{{ . }}"
|
{{- $u := urls.Parse .Destination -}}
|
||||||
{{- end }}
|
{{- $href := $u.String -}}
|
||||||
{{- if or (strings.HasPrefix .Destination "http:") (strings.HasPrefix .Destination "https:") }}
|
{{- if strings.HasPrefix $u.String "#" -}}
|
||||||
target="_blank"
|
{{- $href = printf "%s#%s" .PageInner.RelPermalink $u.Fragment -}}
|
||||||
{{ end }}>
|
{{- else if and $href (not $u.IsAbs) -}}
|
||||||
|
{{- $path := strings.TrimPrefix "./" $u.Path -}}
|
||||||
|
{{- with or
|
||||||
|
($.PageInner.GetPage $path)
|
||||||
|
($.PageInner.Resources.Get $path)
|
||||||
|
(resources.Get $path)
|
||||||
|
-}}
|
||||||
|
{{- $href = .RelPermalink -}}
|
||||||
|
{{- with $u.RawQuery -}}
|
||||||
|
{{- $href = printf "%s?%s" $href . -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- with $u.Fragment -}}
|
||||||
|
{{- $href = printf "%s#%s" $href . -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
|
||||||
|
<a href="{{ $href }}" {{ with .Title }}title="{{ . }}"{{ end }}
|
||||||
|
{{- if or (strings.HasPrefix .Destination "http:") (strings.HasPrefix .Destination "https:") }} target="_blank"{{ end }}>
|
||||||
{{- .Text | safeHTML -}}
|
{{- .Text | safeHTML -}}
|
||||||
</a>
|
</a>
|
||||||
{{- /* Trim EOF */ -}}
|
{{- /* Trim EOF */ -}}
|
||||||
|
|||||||
Reference in New Issue
Block a user