hugo-theme-relearn/layouts/partials/_relearn/defaultSidebarHeader.gotmpl
Sören Weber 5ba09afb6c
Some checks are pending
docs-build-deployment / Run deploy (push) Waiting to run
docs-build / Run build (push) Waiting to run
theme: add version selector #1050
2025-03-17 23:13:43 +01:00

41 lines
No EOL
1.9 KiB
Go Template

{{- $defaultmenuconfigs := slice }}
{{- $defaultconfigelements := slice }}
{{- if not site.Params.disableLandingPageButton }}
{{- if (ne site.Params.landingPageURL nil) }}
{{- warnf "UNSUPPORTED usage of 'landingPageURL' config parameter found, remove it and optionally overwrite the `logo.html` partial to provide a link if it should not point to the project's home page; see https://mcshelby.github.io/hugo-theme-relearn/introduction/releasenotes/4/#4-2-0" }}
{{- end }}
{{- $title := trim (.Site.Params.landingPageName | plainify) "\n\r\t " }}
{{- $pre := "" }}
{{- $post := "" }}
{{- if $title }}
{{- $escapedTitle := replaceRE `([\.+*?()|[\]{}^$\\])` "\\$1" $title }}
{{- $pre = (replaceRE (printf `%s.*` $escapedTitle) "" site.Params.landingPageName) | safeHTML }}
{{- $post = (replaceRE (printf `.*?%s` $escapedTitle) "" site.Params.landingPageName) | safeHTML }}
{{- else }}
{{- $title = T "home-button" }}
{{- $pre = `<i class="fa-fw fas fa-home"></i> ` | safeHTML }}
{{- end }}
{{- $defaultmenuconfigs = $defaultmenuconfigs | append (dict "type" "divider") }}
{{- $defaultmenuconfigs = $defaultmenuconfigs | append
(dict "type" "menu" "identifier" "homelinks" "disableTitle" true "entries" (slice
(dict "Menu" "" "Children" (slice
(dict "Menu" "" "Pre" $pre "Post" $post "Title" $title "PageRef" "/" )
))
))
}}
{{- end }}
{{- $versions := partialCached "_relearn/siteVersions.gotmpl" . }}
{{- if $versions }}
{{- $defaultconfigelements = $defaultconfigelements | append (dict "type" "versionswitcher") }}
{{- end }}
{{- if $defaultconfigelements }}
{{- $defaultmenuconfigs = $defaultmenuconfigs | append
(dict "type" "custom" "identifier" "controls" "disableTitle" true "elements" $defaultconfigelements)
}}
{{- end }}
{{- $defaultmenuconfigs = $defaultmenuconfigs | append (dict "type" "divider") }}
{{- return $defaultmenuconfigs }}