Return to top menu item (#156)

Opt-in "Return To Top" navigation menu entry, implements #154
This commit is contained in:
spi 2023-10-04 21:15:55 +02:00 committed by GitHub
parent 9e20c65ad8
commit c547893371
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 0 deletions

View file

@ -11,4 +11,10 @@ header_logo: "images/chef-hat.png"
# Headers are safeHTML, you can use HTML tags such as b,i,u,br
header_headline: "Jane Doe"
header_subheadline: "<b>Nutrition</b> Coach & <b>Chef</b> Consultant"
# Add a 'Go back to top' item to the navigation menu
# Title: name of navigation menu entry
# Weight (i. e. position in menu): none = no menu entry, first = add as first entry, last = ad as last entry
nav_to_top_title: "Return To Top"
nav_to_top_weight: last
---

View file

@ -50,9 +50,19 @@
<main class="content" role="main">
<!-- Render sticky left navigation menu -->
<div class='fixed-nav'>
{{ if eq .Params.nav_to_top_weight "first" }}
{{ $fnav_title := "Start" }}{{ with .Params.nav_to_top_title }}{{ $fnav_title = . }}{{ end }}
<a class='fn-item' item_index='{{ 0 }}' href='/#site-head'>{{ $fnav_title | safeHTML }}</a>
{{ end }}
{{ $last_index_val := 0 }}
{{ range $index_val, $elem_val := $content }}
{{ $fnav_title := .Title }}{{ with .Params.navigation_menu_title }}{{ $fnav_title = . }}{{ end }}
<a class='fn-item' item_index='{{ (add $index_val 1) }}' href='#{{ anchorize $fnav_title }}'>{{ $fnav_title | safeHTML }}</a>
{{ $last_index_val = $index_val }}
{{ end }}
{{ if eq .Params.nav_to_top_weight "last" }}
{{ $fnav_title := "Start" }}{{ with .Params.nav_to_top_title }}{{ $fnav_title = . }}{{ end }}
<a class='fn-item' item_index='{{ (add $last_index_val 2) }}' href='/#site-head'>{{ $fnav_title | safeHTML }}</a>
{{ end }}
</div>