|
126 | 126 | <script src="{{ $js_algolia_search.RelPermalink }}" type="module"></script>
|
127 | 127 | {{ end }}
|
128 | 128 |
|
129 |
| -{{/* Page Data */}} |
130 |
| -{{ $default_headroom := not (.IsHome | or (eq .Type "book")) }} |
131 |
| -{{ $use_headroom := cond (isset $.Params "header.on_scroll") (eq $.Params.header.on_scroll "disappear") (default $default_headroom) }} |
| 129 | +{{/* Headroom */}} |
| 130 | +{{/* |
| 131 | + Headroom JS enables hiding the header on scrolling down and showing it on scrolling up. |
| 132 | + This is especially valuable on smaller displays such as mobile devices. |
| 133 | + This option can be set in the following ways: |
| 134 | + - globally, in the site's 'params.yaml': |
| 135 | + ``` |
| 136 | + header: |
| 137 | + on_scroll: "disappear" | "sticky" |
| 138 | + ``` |
| 139 | + - per page, in the page front matter: |
| 140 | + ``` |
| 141 | + header: |
| 142 | + on_scroll: "disappear" | "sticky" |
| 143 | + ``` |
| 144 | + When the header is set to disappear, the Headroom JS is loaded. |
| 145 | + |
| 146 | + By default, the header is sticky in the homepage and in the book layout, |
| 147 | + and it disappears when scrolling in all other pages. |
| 148 | +*/}} |
| 149 | + |
| 150 | +{{/* By default don't use Headroom in the homepage and book layout */}} |
| 151 | +{{ $use_headroom := not (.IsHome | or (eq .Type "book")) }} |
| 152 | + |
| 153 | +{{/* Check for the global site parameter `header.on_scroll` */}} |
| 154 | +{{ if (isset site.Params.header "on_scroll") }} |
| 155 | + {{ $use_headroom = eq site.Params.header.on_scroll "disappear" }} |
| 156 | +{{ end }} |
| 157 | + |
| 158 | +{{/* Check for the page parameter `header.on_scroll` */}} |
| 159 | +{{ if (isset $.Params.header "on_scroll") }} |
| 160 | + {{ $use_headroom = eq $.Params.header.on_scroll "disappear" }} |
| 161 | +{{ end }} |
| 162 | + |
| 163 | +{{/* Output `use_headroom` variable for Headroom initialization in Wowchemy JS */}} |
132 | 164 | {{ printf "<script id=\"page-data\" type=\"application/json\">%s</script>" (dict "use_headroom" $use_headroom | jsonify) | safeHTML}}
|
133 | 165 |
|
134 |
| -{{/* Headroom */}} |
135 | 166 | {{ if $use_headroom }}
|
136 | 167 | {{ $headroom := resources.Get "js/wowchemy-headroom.js" | js.Build (dict "format" "esm" "minify" true) }}
|
137 | 168 | {{- if hugo.IsProduction -}}
|
|
0 commit comments