menu: support for link effects #1008

This commit is contained in:
Sören Weber 2025-02-07 22:00:13 +01:00
parent 72099590d4
commit 109d094dc2
No known key found for this signature in database
GPG key ID: BEC6D55545451B6D
5 changed files with 87 additions and 25 deletions

View file

@ -138,11 +138,13 @@ summaryLength = 10
pre = '<i class="fa-fw fab fa-hackerrank"></i> '
name = 'Hugo'
url = 'https://gohugo.io/documentation/'
weight = 1
[[languages.en.menu.devshortcuts]]
parent = 'devshortcuts'
pre = '<i class="fa-fw fas fa-puzzle-piece"></i> '
identifier = 'theme'
name = 'Theme'
weight = 2
[[languages.en.menu.devshortcuts.params]]
alwaysopen = true
[[languages.en.menu.devshortcuts]]
@ -150,18 +152,27 @@ summaryLength = 10
pre = '<i class="fa-fw fas fa-gears"></i> '
identifier = 'configoptions'
pageRef = 'configuration/reference'
weight = 1
[[languages.en.menu.devshortcuts]]
parent = 'theme'
pre = '<i class="fa-fw fab fa-markdown"></i> '
identifier = 'frontmatter'
title = 'Front Matter Reference'
pageRef = 'authoring/frontmatter/reference#annotated-front-matter'
weight = 2
[[languages.en.menu.devshortcuts]]
parent = 'theme'
pre = '<i class="fa-fw fas fa-image"></i> '
identifier = 'screenshotframe'
title = 'Screenshot Frame'
pageRef = 'images/hero.zip'
weight = 3
[[languages.en.menu.devshortcuts]]
parent = 'theme'
pre = '<i class="fa-fw fas fa-wand-magic-sparkles"></i> '
title = 'Maaagic Download'
pageRef = 'images/magic.gif?download'
weight = 4
# this is ourrr way t' showcase th' multilang settings by
# doing autotrrranlat'n of th' english content; we are
@ -216,11 +227,13 @@ summaryLength = 10
pre = '<i class="fa-fw fab fa-hackerrank"></i> '
name = "Cap'n Hugo"
url = 'https://gohugo.io/documentation/'
weight = 1
[[languages.pir.menu.devshortcuts]]
parent = 'devshortcuts'
pre = '<i class="fa-fw fas fa-puzzle-piece"></i> '
identifier = 'theme'
name = "Th' Theme"
weight = 2
[[languages.pir.menu.devshortcuts.params]]
alwaysopen = true
[[languages.pir.menu.devshortcuts]]
@ -228,18 +241,27 @@ summaryLength = 10
pre = '<i class="fa-fw fas fa-gears"></i> '
identifier = 'configoptions'
pageRef = 'configuration/reference'
weight = 1
[[languages.pir.menu.devshortcuts]]
parent = 'theme'
pre = '<i class="fa-fw fab fa-markdown"></i> '
identifier = 'frontmatter'
title = 'Front Matter Reference'
pageRef = 'authoring/frontmatter/reference#annotated-front-matter'
weight = 2
[[languages.pir.menu.devshortcuts]]
parent = 'theme'
pre = '<i class="fa-fw fas fa-image"></i> '
identifier = 'screenshotframe'
title = 'Screenshot Frame'
pageRef = 'images/hero.zip'
weight = 3
[[languages.pir.menu.devshortcuts]]
parent = 'theme'
pre = '<i class="fa-fw fas fa-wand-magic-sparkles"></i> '
title = 'Maaagic Download'
pageRef = 'images/magic.gif?download'
weight = 4
# 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

View file

@ -1,4 +1,4 @@
{{- $attributes := dict }}
{{- $attributes := .attributes | default dict }}
{{- $height := "auto" }}
{{- $width := "auto" }}
{{- $effects := dict "border" false "lazy" true "lightbox" true "shadow" false }}
@ -63,7 +63,7 @@
{{- end }}
{{- end }}
{{- end }}
{{- if $attributes.class }}{{ $classes = $classes | append $attributes.class }}{{ end }}
{{- if $attributes.class }}{{ $classes = $classes | append (split $attributes.class " ") }}{{ end }}
{{- $attributes = merge $attributes (dict "class" (delimit $classes " ")) }}
{{- $attributes = merge $attributes (dict "src" .url) }}
{{- $attributes = merge $attributes (dict "style" (printf " height: %s; width: %s;%s" $height $width (index $attributes "style" | default ""))) }}

View file

@ -1,4 +1,4 @@
{{- $attributes := dict }}
{{- $attributes := .attributes | default dict }}
{{- /* target will be boolean false if no user defined value was set and effect default should be applied */}}
{{- $target := false }}
{{- $u := urls.Parse .url }}
@ -64,7 +64,7 @@
{{- end }}
{{- end }}
{{- end }}
{{- if $attributes.class }}{{ $classes = $classes | append $attributes.class }}{{ end }}
{{- if $attributes.class }}{{ $classes = $classes | append (split $attributes.class " ") }}{{ end }}
{{- $attributes = merge $attributes (dict "class" (delimit $classes " ")) }}
{{- $attributes = merge $attributes (dict "href" .url) }}
{{- $attributes = merge $attributes (dict "download" $effects.download) }}

View file

@ -169,7 +169,6 @@
{{- $title := partial "title.gotmpl" (dict "page" . "linkTitle" true) }}
{{- $url := partial "permalink.gotmpl" (dict "to" .) }}
{{- $isCrosslink := false }}
{{- $target := "" }}
{{- if .Params.menuPageRef }}
{{- $isCrosslink = true }}
{{- $url = .Params.menuPageRef }}
@ -180,13 +179,6 @@
{{- else if .Params.menuUrl }}
{{- $isCrosslink = true }}
{{- $url = .Params.menuUrl | relLangURL }}
{{- $u := urls.Parse $url }}
{{- if $u.IsAbs }}
{{- $target = "_blank" }}
{{- if isset site.Params "externallinktarget" }}
{{- $target = site.Params.externalLinkTarget }}
{{- end }}
{{- end }}
{{- end }}
{{- $pre := partial "menu-pre.html" . }}
{{- $post := partial "menu-post.html" . }}
@ -200,7 +192,21 @@
{{- $isOpen := or $currentAlwaysopen $isSelf $isAncestor }}
<li class="{{if $isActive }}active {{end}}{{if (or $isSelf $isAncestor) }}parent {{end}}{{if $isHidden }}hidden {{end}}{{if not $url }}headless {{end}}{{if $currentAlwaysopen}}alwaysopen {{end}}" data-nav-id="{{ $url }}">
{{- if $isCollapsible }}<input type="checkbox" id="R-section-{{ $entryId }}" aria-controls="R-subsections-{{ $entryId }}"{{ if $isOpen }} checked{{ end }}><label for="R-section-{{ $entryId }}"><i class="fa-fw fas fa-chevron-right"></i><span class="a11y-only">{{ T "Submenu" $title }}</span></label>{{ end }}
{{- if $url }}<a class="padding" href="{{ $url }}"{{ if $target }} target="{{ $target }}"{{ end }}>{{ else }}<span class="padding">{{ end }}
{{- if $url }}
{{- $attributes := partial "_relearn/linkAttributes.gotmpl" (dict "url" $url "page" $currentNode "attributes" (dict "class" "padding")) -}}
<a
{{- range $k, $v := $attributes }}
{{- if $v }}
{{- if eq (printf "%T" $v) "bool" }}
{{- printf " %s" $k | safeHTMLAttr }}
{{- else }}
{{- printf " %s=%q" $k $v | safeHTMLAttr }}
{{- end }}
{{- end }}
{{- end }}>
{{- else -}}
<span class="padding">
{{- end }}
{{- $pre }}{{ $title }}{{ $post }}
{{- if $url }}{{ if $showvisitedlinks }}<i class="fa-fw fas fa-check read-icon"></i>{{ end }}</a>{{ else }}</span>{{ end }}<ul id="R-subsections-{{ $entryId }}" class="collapsible-menu">
{{- $defaultAlwaysopen := site.Params.alwaysopen | default true }}
@ -218,7 +224,21 @@
{{- end }}</ul></li>
{{- else if $url }}
<li class="{{if $isActive }}active {{end}}{{if $isHidden }}hidden {{end}}{{if not $url }}headless {{end}}{{if $isCrosslink }}crosslink {{end}}" data-nav-id="{{ $url }}">
{{- if $url }}<a class="padding" href="{{ $url }}"{{ if $target }} target="{{ $target }}"{{ end }}>{{ else }}<span class="padding">{{ end }}
{{- if $url }}
{{- $attributes := partial "_relearn/linkAttributes.gotmpl" (dict "url" $url "page" $currentNode "attributes" (dict "class" "padding")) -}}
<a
{{- range $k, $v := $attributes }}
{{- if $v }}
{{- if eq (printf "%T" $v) "bool" }}
{{- printf " %s" $k | safeHTMLAttr }}
{{- else }}
{{- printf " %s=%q" $k $v | safeHTMLAttr }}
{{- end }}
{{- end }}
{{- end }}>
{{- else -}}
<span class="padding">
{{- end }}
{{- $pre }}{{ $title }}{{ $post }}
{{- if $url }}{{ if $showvisitedlinks }}<i class="fa-fw fas fa-check read-icon"></i>{{ end }}</a>{{ else }}</span>{{ end }}</li>
{{- end }}
@ -315,14 +335,6 @@
{{- end }}
{{- $title := partial "_relearn/menuTitle.gotmpl" (dict "page" $currentNode "menu" .) }}
{{- $url := partial "_relearn/menuPermalink.gotmpl" (dict "page" $currentNode "menu" .) }}
{{- $target := "" }}
{{- $u := urls.Parse $url }}
{{- if $u.IsAbs }}
{{- $target = "_blank" }}
{{- if isset site.Params "externallinktarget" }}
{{- $target = site.Params.externalLinkTarget }}
{{- end }}
{{- end }}
{{- $pre := .Pre }}
{{- $post := .Post }}
{{- with $entryObject }}
@ -339,7 +351,21 @@
{{- $isOpen := or $currentAlwaysopen $isSelf $isAncestor }}
<li class="{{if $isActive }}active {{end}}{{if (or $isSelf $isAncestor) }}parent {{end}}{{if $isHidden }}hidden {{end}}{{if not $url }}headless {{end}}{{if $currentAlwaysopen}}alwaysopen {{end}}" data-nav-id="{{ $url }}">
{{- if $isCollapsible }}<input type="checkbox" id="R-section-{{ $entryId }}" aria-controls="R-subsections-{{ $entryId }}"{{ if $isOpen }} checked{{ end }}><label for="R-section-{{ $entryId }}"><i class="fa-fw fas fa-chevron-right"></i><span class="a11y-only">{{ T "Submenu" $title }}</span></label>{{ end }}
{{- if $url }}<a class="padding" href="{{ $url }}"{{ if gt (len $target) 0 }} target="{{ $target }}"{{ end }}>{{ else }}<span class="padding">{{ end }}
{{- if $url }}
{{- $attributes := partial "_relearn/linkAttributes.gotmpl" (dict "url" $url "page" $currentNode "attributes" (dict "class" "padding")) -}}
<a
{{- range $k, $v := $attributes }}
{{- if $v }}
{{- if eq (printf "%T" $v) "bool" }}
{{- printf " %s" $k | safeHTMLAttr }}
{{- else }}
{{- printf " %s=%q" $k $v | safeHTMLAttr }}
{{- end }}
{{- end }}
{{- end }}>
{{- else -}}
<span class="padding">
{{- end }}
{{- $pre }}{{ $title }}{{ $post }}
{{- if $url }}{{ if $showvisitedlinks }}<i class="fa-fw fas fa-check read-icon"></i>{{ end }}</a>{{ else }}</span>{{ end }}<ul id="R-subsections-{{ $entryId }}" class="collapsible-menu">
{{- $defaultAlwaysopen := site.Params.alwaysopen | default true }}
@ -358,7 +384,21 @@
{{- end }}</ul></li>
{{- else if $url }}
<li class="{{if $isActive }}active {{end}}{{if $isHidden }}hidden {{end}}{{if not $url }}headless {{end}}" data-nav-id="{{ $url }}">
{{- if $url }}<a class="padding" href="{{ $url }}"{{ if gt (len $target) 0 }} target="{{ $target }}"{{ end }}>{{ else }}<span class="padding">{{ end }}
{{- if $url }}
{{- $attributes := partial "_relearn/linkAttributes.gotmpl" (dict "url" $url "page" $currentNode "attributes" (dict "class" "padding")) -}}
<a
{{- range $k, $v := $attributes }}
{{- if $v }}
{{- if eq (printf "%T" $v) "bool" }}
{{- printf " %s" $k | safeHTMLAttr }}
{{- else }}
{{- printf " %s=%q" $k $v | safeHTMLAttr }}
{{- end }}
{{- end }}
{{- end }}>
{{- else -}}
<span class="padding">
{{- end }}
{{- $pre }}{{ $title }}{{ $post }}
{{- if $url }}{{ if $showvisitedlinks }}<i class="fa-fw fas fa-check read-icon"></i>{{ end }}</a>{{ else }}</span>{{ end }}</li>
{{- end }}

View file

@ -1 +1 @@
7.3.2+83860202296af0be408eba2a8145c8325403ce04
7.3.2+72099590d4409d0086ea4b9f6f3188e6847028e6