mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2025-02-13 15:23:30 +00:00
25 lines
No EOL
1.4 KiB
Go Template
25 lines
No EOL
1.4 KiB
Go Template
{{- $url := "" }}
|
|
{{- /* because Hugo can not resolve a pageRef if it contains URL query params or
|
|
fragments, we simply don't access the .Page here */}}
|
|
{{- with and . .menu }}
|
|
{{- if .PageRef }}
|
|
{{- $url = .PageRef }}
|
|
{{- $linkObject := partial "_relearn/refObject.gotmpl" (dict "page" $.page "objectRef" .PageRef "refObject" .Page) }}
|
|
{{- if $linkObject }}
|
|
{{- $url = partial "_relearn/decoratedLink.gotmpl" (dict "url" .PageRef "page" $.page "linkObject" $linkObject "param" "link" "hideFilepath" true) }}
|
|
{{- else }}
|
|
{{- $msg := printf "config option 'pageRef' %q for 'menu' entry %q is not a page or a resource" .PageRef (or .KeyName .Identifier .Name .Title) }}
|
|
{{- partial "_relearn/urlErrorReport.gotmpl" (dict "url" .PageRef "page" $.page "param" "link" "msg" $msg) }}
|
|
{{- end }}
|
|
{{- else if .URL }}
|
|
{{- $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 "config option 'url' %q for 'menu' entry %q is a local URL; if it references a page or a resource use 'pageRef' instead" .URL (or .KeyName .Identifier .Name .Title) }}
|
|
{{- partial "_relearn/urlErrorReport.gotmpl" (dict "url" .URL "page" $.page "param" "link" "msg" $msg) }}
|
|
{{- end }}
|
|
{{- end }}
|
|
{{- end }}
|
|
{{- return $url }} |