mirror of https://github.com/jpanther/congo.git
🔀 Merge pull request #691 from stereobooster/portable-links-2
Print warning if system can't resolve link to a markdown filepull/723/head
commit
041fc30fe9
|
@ -2,10 +2,16 @@
|
||||||
{{- $isRemote := strings.HasPrefix $link "http" -}}
|
{{- $isRemote := strings.HasPrefix $link "http" -}}
|
||||||
{{- if not $isRemote }}
|
{{- if not $isRemote }}
|
||||||
{{ $url := urls.Parse .Destination }}
|
{{ $url := urls.Parse .Destination }}
|
||||||
{{ if $url.Path }}
|
{{- if $url.Path }}
|
||||||
{{ $fragment := "" }}
|
{{ $fragment := "" }}
|
||||||
{{- with $url.Fragment }}{{ $fragment = printf "#%s" . }}{{ end -}}
|
{{- with $url.Fragment }}{{ $fragment = printf "#%s" . }}{{ end -}}
|
||||||
{{- with .Page.GetPage $url.Path }}{{ $link = printf "%s%s" .RelPermalink $fragment }}{{ end -}}
|
{{- with .Page.GetPage $url.Path }}
|
||||||
{{ end }}
|
{{ $link = printf "%s%s" .RelPermalink $fragment }}
|
||||||
|
{{ else }}
|
||||||
|
{{- if hasSuffix $url.Path ".md" }}
|
||||||
|
{{ warnf "Can't resolve: %s" .Destination }}
|
||||||
|
{{ end -}}
|
||||||
|
{{ end -}}
|
||||||
|
{{ end -}}
|
||||||
{{ end -}}
|
{{ end -}}
|
||||||
<a href="{{ $link | safeURL }}"{{ with .Title }} title="{{ . }}"{{ end }}{{ if $isRemote }} target="_blank" rel="noreferrer"{{ end }}>{{- .Text | safeHTML -}}</a>
|
<a href="{{ $link | safeURL }}"{{ with .Title }} title="{{ . }}"{{ end }}{{ if $isRemote }} target="_blank" rel="noreferrer"{{ end }}>{{- .Text | safeHTML -}}</a>
|
Loading…
Reference in New Issue