mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2025-01-31 08:57:15 +00:00
32 lines
No EOL
1.1 KiB
Go Template
32 lines
No EOL
1.1 KiB
Go Template
{{- $url := "" }}
|
|
{{- with .menu }}
|
|
{{- $errorlevel := or $.page.Params.link.errorlevel $.page.Site.Params.link.errorlevel }}
|
|
{{- if .PageRef }}
|
|
{{- with .Page }}
|
|
{{- $url = partial "permalink.gotmpl" (dict "to" .) }}
|
|
{{- else }}
|
|
{{- $msg := printf "%q: config menu link '%s' is not a page" $.page.File.Filename .PageRef }}
|
|
{{- if eq $errorlevel "warning" }}
|
|
{{- warnf $msg }}
|
|
{{- else if eq $errorlevel "error" }}
|
|
{{- errorf $msg }}
|
|
{{- end }}
|
|
{{- end }}
|
|
{{- else }}
|
|
{{- with .URL }}
|
|
{{- $url = . | relLangURL }}
|
|
{{- $u := urls.Parse $url }}
|
|
{{- if $u.IsAbs }}
|
|
{{- partialCached "_relearn/urlExists.gotmpl" (dict "url" $url "page" $.page "type" "menu link") $u.String }}
|
|
{{- else }}
|
|
{{- $msg := printf "%q: config menu link '%s' given by 'URL' is not verified; if it is a page use 'PageRef' instead" $.page.File.Filename . }}
|
|
{{- if eq $errorlevel "warning" }}
|
|
{{- warnf $msg }}
|
|
{{- else if eq $errorlevel "error" }}
|
|
{{- errorf $msg }}
|
|
{{- end }}
|
|
{{- end }}
|
|
{{- end }}
|
|
{{- end }}
|
|
{{- end }}
|
|
{{- return $url }} |