diff --git a/docs/config/_default/hugo.toml b/docs/config/_default/hugo.toml index d0a8f03e5c..ad7a8dc82e 100644 --- a/docs/config/_default/hugo.toml +++ b/docs/config/_default/hugo.toml @@ -156,6 +156,12 @@ summaryLength = 10 identifier = 'frontmatter' title = 'Front Matter Reference' pageRef = 'authoring/frontmatter/reference#annotated-front-matter' + [[languages.en.menu.devshortcuts]] + parent = 'theme' + pre = ' ' + identifier = 'screenshotframe' + title = 'Screenshot Frame' + pageRef = 'images/hero.zip' # this is ourrr way t' showcase th' multilang settings by # doing autotrrranlat'n of th' english content; we are @@ -228,6 +234,12 @@ summaryLength = 10 identifier = 'frontmatter' title = 'Front Matter Reference' pageRef = 'authoring/frontmatter/reference#annotated-front-matter' + [[languages.pir.menu.devshortcuts]] + parent = 'theme' + pre = ' ' + identifier = 'screenshotframe' + title = 'Screenshot Frame' + pageRef = 'images/hero.zip' # mounts are only needed in this showcase to access the publicly available screenshots and CHANGELOG; # remove this section if you don't need further mounts diff --git a/layouts/partials/_relearn/decoratedLink.gotmpl b/layouts/partials/_relearn/decoratedLink.gotmpl index 39a5dedaa6..2be07ef583 100644 --- a/layouts/partials/_relearn/decoratedLink.gotmpl +++ b/layouts/partials/_relearn/decoratedLink.gotmpl @@ -1,4 +1,4 @@ -{{- $href := partial "permalink.gotmpl" (dict "to" .linkPage) }} +{{- $href := partial "permalink.gotmpl" (dict "to" .linkObject) }} {{- $silent := .silent | default false }} {{- $hideFilepath := .hideFilepath | default false }} {{- $u := urls.Parse .url }} @@ -8,7 +8,7 @@ {{- with $u.Fragment }} {{- $href = printf "%s#%s" $href . }} {{- if not $silent }} - {{- partial "inline/validate-fragment.html" (dict "origPage" $.page "page" $.linkPage "parsedURL" $u "url" $.url "param" $.param "hideFilepath" $hideFilepath) }} + {{- partial "inline/validate-fragment.html" (dict "origPage" $.page "page" $.linkObject "parsedURL" $u "url" $.url "param" $.param "hideFilepath" $hideFilepath) }} {{- end }} {{- end }} {{- return $href }} diff --git a/layouts/partials/_relearn/linkPage.gotmpl b/layouts/partials/_relearn/linkObject.gotmpl similarity index 91% rename from layouts/partials/_relearn/linkPage.gotmpl rename to layouts/partials/_relearn/linkObject.gotmpl index 455d688538..7a08aa31c2 100644 --- a/layouts/partials/_relearn/linkPage.gotmpl +++ b/layouts/partials/_relearn/linkObject.gotmpl @@ -1,5 +1,5 @@ {{- $page := .page }} -{{- $linkPage := "" }} +{{- $linkObject := "" }} {{- $u := urls.Parse .url }} {{- $path := strings.TrimPrefix "./" $u.Path }} {{- $searchLocal := .searchLocal | default true }} @@ -15,7 +15,7 @@ (and $searchLocal $searchResource ($page.Page.Resources.Get $path)) (and $searchGlobal $searchResource (resources.Get $path)) }} - {{- $linkPage = . }} + {{- $linkObject = . }} {{- else }} {{- /* is it a link into another translation? */}} {{- if strings.HasPrefix $path "/" }} @@ -35,7 +35,7 @@ (and $searchLocal $searchResource (.Resources.Get $suffix)) (and $searchGlobal $searchResource (resources.Get $suffix)) }} - {{- $linkPage = . }} + {{- $linkObject = . }} {{- break }} {{- end }} {{- end }} @@ -43,6 +43,6 @@ {{- end }} {{- end }} {{- else }} - {{- $linkPage = $page.Page }} + {{- $linkObject = $page.Page }} {{- end }} -{{- return $linkPage }} \ No newline at end of file +{{- return $linkObject }} \ No newline at end of file diff --git a/layouts/partials/_relearn/menuObject.gotmpl b/layouts/partials/_relearn/menuObject.gotmpl new file mode 100644 index 0000000000..76c7df8f28 --- /dev/null +++ b/layouts/partials/_relearn/menuObject.gotmpl @@ -0,0 +1,5 @@ +{{- $linkObject := "" }} +{{- with and . .menu }} + {{- $linkObject = partial "_relearn/refObject.gotmpl" (dict "page" $.page "objectRef" .PageRef "refObject" .Page "searchPage" $.searchPage "searchResource" $.searchResource) }} +{{- end }} +{{- return $linkObject }} \ No newline at end of file diff --git a/layouts/partials/_relearn/menuPage.gotmpl b/layouts/partials/_relearn/menuPage.gotmpl deleted file mode 100644 index 32b44bd420..0000000000 --- a/layouts/partials/_relearn/menuPage.gotmpl +++ /dev/null @@ -1,5 +0,0 @@ -{{- $linkPage := "" }} -{{- with and . .menu }} - {{- $linkPage = partial "_relearn/refPage.gotmpl" (dict "page" $.page "pageRef" .PageRef "refPage" .Page) }} -{{- end }} -{{- return $linkPage }} \ No newline at end of file diff --git a/layouts/partials/_relearn/menuPermalink.gotmpl b/layouts/partials/_relearn/menuPermalink.gotmpl index 8fcadb47ea..313f37ac97 100644 --- a/layouts/partials/_relearn/menuPermalink.gotmpl +++ b/layouts/partials/_relearn/menuPermalink.gotmpl @@ -4,9 +4,9 @@ {{- with and . .menu }} {{- if .PageRef }} {{- $url = .PageRef }} - {{- $linkPage := partial "_relearn/refPage.gotmpl" (dict "page" $.page "pageRef" .PageRef "refPage" .Page) }} - {{- if $linkPage }} - {{- $url = partial "_relearn/decoratedLink.gotmpl" (dict "url" .PageRef "page" $.page "linkPage" $linkPage "param" "link" "hideFilepath" true) }} + {{- $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) }} diff --git a/layouts/partials/_relearn/menuTitle.gotmpl b/layouts/partials/_relearn/menuTitle.gotmpl index ddf8c44ac1..7e517e738a 100644 --- a/layouts/partials/_relearn/menuTitle.gotmpl +++ b/layouts/partials/_relearn/menuTitle.gotmpl @@ -1,10 +1,18 @@ {{- $title := "" }} {{- with and . .menu }} - {{- $pagetitle := "" }} - {{- $menuPage := partial "_relearn/menuPage.gotmpl" (dict "page" $.page "menu" .) }} + {{- $objectTitle := "" }} + {{- $menuPage := partial "_relearn/menuObject.gotmpl" (dict "page" $.page "menu" . "searchResource" false) }} {{- with $menuPage }} - {{- $pagetitle = or .LinkTitle .Title }} + {{- $objectTitle = or .LinkTitle .Title }} + {{- else }} + {{- $menuResource := partial "_relearn/menuObject.gotmpl" (dict "page" $.page "menu" . "searchPage" false) }} + {{- with $menuResource }} + {{- $objectTitle = .Title }} + {{- end }} + {{- end }} + {{- $title = or .Title (.Name | safeHTML) (.Identifier | safeHTML) }} + {{- if and (eq $objectTitle .Title) (ne .Name .Title) }} + {{- $title = (.Name | safeHTML) }} {{- end }} - {{- $title = or .Title $pagetitle (.Name | safeHTML) (.Identifier | safeHTML) }} {{- end }} {{- return $title }} \ No newline at end of file diff --git a/layouts/partials/_relearn/refObject.gotmpl b/layouts/partials/_relearn/refObject.gotmpl new file mode 100644 index 0000000000..84fa583e1d --- /dev/null +++ b/layouts/partials/_relearn/refObject.gotmpl @@ -0,0 +1,11 @@ +{{- $linkObject := "" }} +{{- /* because Hugo can not resolve a pageRef if it contains URL query params or + fragments, we do it ourself if we detect such a case */}} +{{- with .refObject }} + {{- $linkObject = . }} +{{- else }} + {{- with .objectRef }} + {{- $linkObject = partial "_relearn/linkObject.gotmpl" (dict "url" . "page" $.page "searchLocal" false "searchPage" $.searchPage "searchResource" $.searchResource) }} + {{- end }} +{{- end }} +{{- return $linkObject }} \ No newline at end of file diff --git a/layouts/partials/_relearn/refPage.gotmpl b/layouts/partials/_relearn/refPage.gotmpl deleted file mode 100644 index e4fe52a1c8..0000000000 --- a/layouts/partials/_relearn/refPage.gotmpl +++ /dev/null @@ -1,11 +0,0 @@ -{{- $linkPage := "" }} -{{- /* because Hugo can not resolve a pageRef if it contains URL query params or - fragments, we do it ourself if we detect such a case */}} -{{- with .refPage }} - {{- $linkPage = . }} -{{- else }} - {{- with .pageRef }} - {{- $linkPage = partial "_relearn/linkPage.gotmpl" (dict "url" . "page" $.page "searchLocal" false) }} - {{- end }} -{{- end }} -{{- return $linkPage }} \ No newline at end of file diff --git a/layouts/partials/menu.html b/layouts/partials/menu.html index dc2e350a3e..7200275666 100644 --- a/layouts/partials/menu.html +++ b/layouts/partials/menu.html @@ -105,15 +105,15 @@ {{- $config := .config }} {{- $showvisitedlinks := .showvisitedlinks }}
- {{- $root := site.Home }} + {{- $rootObject := site.Home }} {{- if $config.pageRef }} - {{- $root = partial "_relearn/refPage.gotmpl" (dict "page" $currentNode "pageRef" $config.pageRef) }} - {{- if not $root }} + {{- $rootObject = partial "_relearn/refObject.gotmpl" (dict "page" $currentNode "objectRef" $config.pageRef) }} + {{- if not $rootObject }} {{- $msg := printf "config option 'pageRef' %q for 'sidebarmenus' %q is not a page or a resource" $config.pageRef $config.identifier }} {{- partial "_relearn/urlErrorReport.gotmpl" (dict "url" $config.pageRef "page" $currentNode "param" "link" "msg" $msg) }} {{- end }} {{- end }} - {{- with $root }} + {{- with $rootObject }} {{- $entry := . }} {{- $entries := partialCached "_relearn/pages.gotmpl" (dict "page" $entry) $entry.Path }} {{- $title := "" }} @@ -173,9 +173,9 @@ {{- if .Params.menuPageRef }} {{- $isCrosslink = true }} {{- $url = .Params.menuPageRef }} - {{- $linkPage := partial "_relearn/refPage.gotmpl" (dict "page" . "pageRef" .Params.menuPageRef) }} - {{- if $linkPage }} - {{- $url = partial "_relearn/decoratedLink.gotmpl" (dict "url" .Params.menuPageRef "page" . "linkPage" $linkPage "param" "link" "silent" true) }} + {{- $linkObject := partial "_relearn/refObject.gotmpl" (dict "page" . "objectRef" .Params.menuPageRef) }} + {{- if $linkObject }} + {{- $url = partial "_relearn/decoratedLink.gotmpl" (dict "url" .Params.menuPageRef "page" . "linkObject" $linkObject "param" "link" "silent" true) }} {{- end }} {{- else if .Params.menuUrl }} {{- $isCrosslink = true }} @@ -232,7 +232,7 @@ {{- with index site.Menus $config.identifier }}
{{- $topLevelMenu := "" }} - {{- $topLevelPage := "" }} + {{- $topLevelObject := "" }} {{- $entries := . }} {{- with and (eq (len $entries) 1) (index $entries 0) }} {{- if and (not .PageRef) (not .URL) }} @@ -241,7 +241,7 @@ entry carrys just meta information and parameter, uses its children to build the "real" menu, and has no own `url` or `pageRef` */}} {{- $topLevelMenu = . }} - {{- $topLevelPage = partial "_relearn/menuPage.gotmpl" (dict "page" $currentNode "menu" $topLevelMenu) }} + {{- $topLevelObject = partial "_relearn/menuObject.gotmpl" (dict "page" $currentNode "menu" $topLevelMenu) }} {{- $entries = .Children }} {{- end }} {{- end }} @@ -268,14 +268,14 @@ {{- $root := or $topLevelMenu site }} {{- $defaultAlwaysopen := site.Params.alwaysopen | default false }} {{- range $entries }} - {{- $entriesPage := partial "_relearn/menuPage.gotmpl" (dict "page" $currentNode "menu" .) }} - {{- $isSubSelf := eq $entriesPage $currentNode }} + {{- $entriesObject := partial "_relearn/menuObject.gotmpl" (dict "page" $currentNode "menu" .) }} + {{- $isSubSelf := eq $entriesObject $currentNode }} {{- $isSubAncestor := and (not $isSubSelf) ($currentNode.HasMenuCurrent .Menu .) }} {{- $isSubHidden := or (.Params.hidden) (eq (partial "_relearn/menuTitle.gotmpl" (dict "page" $currentNode "menu" .)) "") }} {{- $isSubCollapsible := .Params.collapsibleMenu | default $root.Params.collapsibleMenu | default site.Params.collapsibleMenu }} {{- if or $isSubSelf $isSubAncestor }} {{- partial "partials/inline/menu-walker" (dict "menu" . "currentnode" $currentNode "showvisitedlinks" $showvisitedlinks "alwaysopen" $defaultAlwaysopen "isSelf" $isSubSelf "isAncestor" $isSubAncestor "isHidden" $isSubHidden "root" $root) }} - {{- else if and (not $isSubHidden) (or $isSubCollapsible (not (partial "_relearn/menuPermalink.gotmpl" (dict "page" $currentNode "menu" $topLevelMenu))) (eq $topLevelPage $currentNode) (and $topLevelMenu ($currentNode.HasMenuCurrent $topLevelMenu.Menu $topLevelMenu))) }} + {{- else if and (not $isSubHidden) (or $isSubCollapsible (not (partial "_relearn/menuPermalink.gotmpl" (dict "page" $currentNode "menu" $topLevelMenu))) (eq $topLevelObject $currentNode) (and $topLevelMenu ($currentNode.HasMenuCurrent $topLevelMenu.Menu $topLevelMenu))) }} {{- $id := md5 (print .) }} {{- partialCached "partials/inline/menu-walker" (dict "menu" . "currentnode" $currentNode "showvisitedlinks" $showvisitedlinks "alwaysopen" $defaultAlwaysopen "isSelf" $isSubSelf "isAncestor" $isSubAncestor "isHidden" $isSubHidden "root" $root) $id }} {{- end }} @@ -300,12 +300,12 @@ {{- with .menu }} {{- $isActive := $isSelf }} {{- $entryMenu := . }} - {{- $entryPage := partial "_relearn/menuPage.gotmpl" (dict "page" $currentNode "menu" $entryMenu) }} + {{- $entryObject := partial "_relearn/menuObject.gotmpl" (dict "page" $currentNode "menu" $entryMenu) }} {{- $entries := .Children }} {{- $hasVisibleChildren := false }} {{- range $entries }} - {{- $entriesPage := partial "_relearn/menuPage.gotmpl" (dict "page" $currentNode "menu" .) }} - {{- $isSubSelf := eq $entriesPage $currentNode }} + {{- $entriesObject := partial "_relearn/menuObject.gotmpl" (dict "page" $currentNode "menu" .) }} + {{- $isSubSelf := eq $entriesObject $currentNode }} {{- $isSubAncestor := and (not $isSubSelf) ($currentNode.HasMenuCurrent .Menu .) }} {{- $isSubHidden := or (.Params.hidden) (eq (partial "_relearn/menuTitle.gotmpl" (dict "page" $currentNode "menu" .)) "") }} {{- if or $isSubAncestor $isSubSelf (not $isSubHidden) }} @@ -325,7 +325,7 @@ {{- end }} {{- $pre := .Pre }} {{- $post := .Post }} - {{- with $entryPage }} + {{- with $entryObject }} {{- $pre = or $pre (partial "menu-pre.html" .) }} {{- $post = or $post (partial "menu-post.html" .) }} {{- end }} @@ -344,14 +344,14 @@ {{- if $url }}{{ if $showvisitedlinks }}{{ end }}{{ else }}{{ end }}