mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2025-01-31 00:47:13 +00:00
menu: DRY code #1002
This commit is contained in:
parent
1205aa0448
commit
9527cd17bb
8 changed files with 26 additions and 32 deletions
|
@ -168,12 +168,6 @@
|
|||
{{- with site.Home.GetPage (.Params.menuPageRef) }}
|
||||
{{- $url = partial "permalink.gotmpl" (dict "to" .) }}
|
||||
{{- $isCrosslink = true }}
|
||||
{{- else }}
|
||||
{{- if eq $errorlevel "warning" }}
|
||||
{{- warnf "%q: menu link '%s' is not a page but linked anyways" $currentNode.File.Filename .Params.menuPageRef }}
|
||||
{{- else if eq $errorlevel "error" }}
|
||||
{{- errorf "%q: menu link '%s' is not a page" $currentNode.File.Filename .Params.menuPageRef }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- else if .Params.menuUrl }}
|
||||
{{- $url = .Params.menuUrl }}
|
||||
|
@ -185,12 +179,6 @@
|
|||
{{- if isset site.Params "externallinktarget" }}
|
||||
{{- $target = site.Params.externalLinkTarget }}
|
||||
{{- end }}
|
||||
{{- else }}
|
||||
{{- if eq $errorlevel "warning" }}
|
||||
{{- warnf "%q: local menu link '%s' was given by 'menuURL'; if it points to a page inside your Hugo site use 'menuPageRef' instead; link created anyways" $currentNode.File.Filename .Params.menuUrl }}
|
||||
{{- else if eq $errorlevel "error" }}
|
||||
{{- errorf "%q: local menu link '%s' was given by 'menuURL'; if it points to a page inside your Hugo site use 'menuPageRef' instead" $currentNode.File.Filename .Params.menuUrl }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- $pre := partial "menu-pre.html" . }}
|
||||
|
|
|
@ -5,10 +5,11 @@
|
|||
{{- 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 "%q: menu link '%s' is not a page but linked anyways" $.page.File.Filename .PageRef }}
|
||||
{{- warnf $msg }}
|
||||
{{- else if eq $errorlevel "error" }}
|
||||
{{- errorf "%q: menu link '%s' is not a page" $.page.File.Filename .PageRef }}
|
||||
{{- errorf $msg }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- else }}
|
||||
|
@ -18,10 +19,11 @@
|
|||
{{- 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 "%q: local menu link '%s' was given by 'URL'; if it points to a page inside your Hugo site use 'pageRef' instead; link created anyways" $.page.File.Filename . }}
|
||||
{{- warnf $msg }}
|
||||
{{- else if eq $errorlevel "error" }}
|
||||
{{- errorf "%q: local menu link '%s' was given by 'URL'; if it points to a page inside your Hugo site use 'pageRef' instead" $.page.File.Filename . }}
|
||||
{{- errorf $msg }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
|
|
@ -20,10 +20,11 @@
|
|||
{{- with site.Home.GetPage (.Params.menuPageRef) }}
|
||||
{{- $url = partial "permalink.gotmpl" (dict "to" .) }}
|
||||
{{- else }}
|
||||
{{- $msg := printf "%q: front matter crosslink '%s' is not a page" .File.Filename .Params.menuPageRef }}
|
||||
{{- if eq $errorlevel "warning" }}
|
||||
{{- warnf "%q: menu link '%s' is not a page but linked anyways" .File.Filename .Params.menuPageRef }}
|
||||
{{- warnf $msg }}
|
||||
{{- else if eq $errorlevel "error" }}
|
||||
{{- errorf "%q: menu link '%s' is not a page" .File.Filename .Params.menuPageRef }}
|
||||
{{- errorf $msg }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- else if .Params.menuUrl }}
|
||||
|
@ -32,10 +33,11 @@
|
|||
{{- if $u.IsAbs }}
|
||||
{{- partialCached "_relearn/urlExists.gotmpl" (dict "url" $url "page" . "type" "menu link") $u.String }}
|
||||
{{- else }}
|
||||
{{- $msg := printf "%q: front matter crosslink '%s' given by 'menuURL' is not verified; if it is a page use 'menuPageRef' instead" .File.Filename .Params.menuUrl }}
|
||||
{{- if eq $errorlevel "warning" }}
|
||||
{{- warnf "%q: local menu link '%s' was given by 'menuURL'; if it points to a page inside your Hugo site use 'menuPageRef' instead; link created anyways" .File.Filename .Params.menuUrl }}
|
||||
{{- warnf $msg }}
|
||||
{{- else if eq $errorlevel "error" }}
|
||||
{{- errorf "%q: local menu link '%s' was given by 'menuURL'; if it points to a page inside your Hugo site use 'menuPageRef' instead" .File.Filename .Params.menuUrl }}
|
||||
{{- errorf $msg }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
|
|
@ -35,10 +35,11 @@
|
|||
{{- end }}
|
||||
{{- else }}
|
||||
{{- $errorlevel := or $page.Params.image.errorlevel $page.Site.Params.image.errorlevel }}
|
||||
{{- $msg := printf "%q: image '%s' is not a resource" $page.File.Filename .url }}
|
||||
{{- if eq $errorlevel "warning" }}
|
||||
{{- warnf "%q: image '%s' is not a resource but linked anyways" $page.File.Filename .url }}
|
||||
{{- warnf $msg }}
|
||||
{{- else if eq $errorlevel "error" }}
|
||||
{{- errorf "%q: image '%s' is not a resource" $page.File.Filename .url }}
|
||||
{{- errorf $msg }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
|
|
@ -18,10 +18,11 @@
|
|||
{{- $content = .file | readFile }}
|
||||
{{- else }}
|
||||
{{- $errorlevel := or $page.Params.include.errorlevel $page.Site.Params.include.errorlevel }}
|
||||
{{- $msg := printf "%q: include '%s' is not a page, a resource or a file" $page.File.Filename .file }}
|
||||
{{- if eq $errorlevel "warning" }}
|
||||
{{- warnf "%q: included file '%s' is not a page, resource or accessible via file system" $page.File.Filename .file }}
|
||||
{{- warnf $msg }}
|
||||
{{- else if eq $errorlevel "error" }}
|
||||
{{- errorf "%q: included file '%s' is not a page, resource or accessible via file system" $page.File.Filename .file }}
|
||||
{{- errorf $msg }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
{{- $attributes = $attributes | merge (dict "title" ($title | transform.HTMLEscape)) }}
|
||||
{{- $content := .content }}
|
||||
{{- $target := .target | default "" }}
|
||||
{{- $u := urls.Parse .url -}}
|
||||
{{- $u := urls.Parse .url }}
|
||||
{{- $href := $u.String }}
|
||||
{{- if $u.IsAbs }}
|
||||
{{- partialCached "_relearn/urlExists.gotmpl" (dict "url" .url "page" $page "type" "link") $u.String }}
|
||||
|
@ -79,10 +79,11 @@
|
|||
{{- $href = printf "%s#%s" $href . }}
|
||||
{{- end }}
|
||||
{{- else }}
|
||||
{{- $msg := printf "%q: link '%s' is not a page or a resource" $page.File.Filename .url }}
|
||||
{{- if eq $errorlevel "warning" }}
|
||||
{{- warnf "%q: link '%s' is not a page or a resource but linked anyways" $page.File.Filename .url }}
|
||||
{{- warnf $msg }}
|
||||
{{- else if eq $errorlevel "error" }}
|
||||
{{- errorf "%q: link '%s' is not a page or a resource" $page.File.Filename .url }}
|
||||
{{- errorf $msg }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
@ -131,12 +132,10 @@
|
|||
{{- else }}
|
||||
{{- $targetPath = .Path }}
|
||||
{{- end }}
|
||||
{{- /* Set common message. */}}
|
||||
{{- $msg := printf "%q: heading ID %q not found in %q" $contentPath . $targetPath }}
|
||||
{{- if eq $targetPath $contentPath }}
|
||||
{{- $msg := printf "%q: heading ID %q not found" $contentPath . }}
|
||||
{{- end }}
|
||||
{{- /* Throw warning or error. */}}
|
||||
{{- if eq $errorLevel "warning" }}
|
||||
{{- warnf $msg }}
|
||||
{{- else if eq $errorLevel "error" }}
|
||||
|
|
|
@ -19,10 +19,11 @@
|
|||
{{- $spec = .Content }}
|
||||
{{- else }}
|
||||
{{- $errorlevel := or $page.Params.openapi.errorlevel $page.Site.Params.openapi.errorlevel }}
|
||||
{{- $msg := printf "%q: OpenAPI spec '%s' is not a resource" $page.File.Filename .src }}
|
||||
{{- if eq $errorlevel "warning" }}
|
||||
{{- warnf "%q: OpenAPI spec link '%s' is not a resource but linked anyways" $page.File.Filename .url }}
|
||||
{{- warnf $msg }}
|
||||
{{- else if eq $errorlevel "error" }}
|
||||
{{- errorf "%q: OpenAPI spec link '%s' is not a resource" $page.File.Filename .url }}
|
||||
{{- errorf $msg }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
|
|
@ -1 +1 @@
|
|||
7.3.2+ba7e3b9b27ff1459815a786b6c6adb5686723b58
|
||||
7.3.2+1205aa0448dcc4400e39e22e532ab4b62bb8b4c6
|
Loading…
Add table
Reference in a new issue