Browse Source

feat: add support for Headroom

When header.on_scroll == "disappear", with sensible defaults
George Cushen 2 years ago
parent
commit
994d21b3dd

+ 1 - 0
package.json

@@ -16,6 +16,7 @@
   "dependencies": {
     "@fortawesome/fontawesome-free": "^5.15.3",
     "bootstrap": "^4.6.0",
+    "headroom.js": "^0.12.0",
     "instant.page": "^5.1.0",
     "jquery": "^3.6.0",
     "medium-zoom": "^1.0.6"

File diff suppressed because it is too large
+ 6 - 0
wowchemy/assets/js/_vendor/headroom.min.js


+ 22 - 0
wowchemy/assets/js/wowchemy-headroom.js

@@ -0,0 +1,22 @@
+/*************************************************
+ *  Wowchemy
+ *  https://github.com/wowchemy/wowchemy-hugo-themes
+ *
+ *  Wowchemy Headroom
+ **************************************************/
+
+import Headroom from './_vendor/headroom.min.js';
+
+let pageData = JSON.parse(document.getElementById('page-data').textContent);
+console.debug(`Use headroom on this page? ${pageData['use_headroom']}`);
+
+if (pageData['use_headroom'] === true) {
+  document.addEventListener('DOMContentLoaded', function () {
+    // Grab header element
+    let myElement = document.querySelector('header');
+    // Construct an instance of Headroom, passing the header
+    let headroom = new Headroom(myElement);
+    // Initialise Headroom
+    headroom.init();
+  });
+}

+ 19 - 5
wowchemy/assets/scss/wowchemy/components/_nav.scss

@@ -2,6 +2,25 @@
  *  Navigation bar
  **************************************************/
 
+.headroom {
+  will-change: transform;
+  transition: transform 200ms linear;
+}
+.headroom--pinned {
+  transform: translateY(0%);
+}
+.headroom--unpinned {
+  transform: translateY(-100%);
+}
+
+.header--fixed {
+  position: fixed;
+  z-index: 10; // previously, 1030
+  right: 0;
+  left: 0;
+  top: 0;
+}
+
 .dropdown-menu {
   background-color: $sta-menu-primary !important;
   color: $sta-menu-text !important;
@@ -13,11 +32,6 @@
   background: $sta-menu-primary;
   box-shadow: 0 0.125rem 0.25rem 0 rgba(0, 0, 0, 0.11);
   font-size: #{$sta-font-size-small}px;
-  position: fixed;
-  top: 0;
-  right: 0;
-  left: 0;
-  z-index: 1030;
 
   // Remove Bootstrap's navbar v-padding and assign v-padding to logo separately to maximise logo size.
   // Otherwise, Bootstrap's navbar v-padding causes issue with logo fitting within fixed 50px height bar in md-lg sizes.

+ 1 - 1
wowchemy/layouts/index.json

@@ -53,7 +53,7 @@
     {{- end -}}
 
     {{- /* Add page to index. */ -}}
-    {{- $index = $index | append (dict "objectID" .File.UniqueID "date" .Date.UTC.Unix "publishdate" .PublishDate "lastmod" .Lastmod.UTC.Unix "expirydate" .ExpiryDate.UTC.Unix "lang" .Lang "permalink" $permalink "relpermalink" $rel_permalink "title" $title "summary" (plainify $desc) "content" .Plain "authors" $authors "kind" .Kind "type" .Type "section" .Section "tags" .Params.Tags "categories" .Params.Categories) -}}
+    {{- $index = $index | append (dict "objectID" .File.UniqueID "date" .Date.UTC.Unix "publishdate" .PublishDate "lastmod" .Lastmod.UTC.Unix "expirydate" .ExpiryDate.UTC.Unix "lang" .Lang "permalink" $permalink "relpermalink" $rel_permalink "title" $title "summary" (plainify $desc | htmlUnescape) "content" (.Plain | htmlUnescape | truncate 5000) "authors" $authors "kind" .Kind "type" .Type "section" .Section "tags" .Params.Tags "categories" .Params.Categories) -}}
 
   {{- end -}}
 {{- end -}}

+ 16 - 1
wowchemy/layouts/partials/components/breadcrumb.html

@@ -1,10 +1,25 @@
 {{ if not .IsHome }}
   <nav class="d-none d-md-flex" aria-label="breadcrumb">
     <ol class="breadcrumb">
-      {{ partial "components/breadcrumb_child" . }}
+      {{ template "breadcrumb" . }}
       <li class="breadcrumb-item active" aria-current="page">
         {{ .LinkTitle | emojify }}
       </li>
     </ol>
   </nav>
 {{ end }}
+
+{{ define "breadcrumb" }}
+  {{ with .Parent }}
+    {{ template "breadcrumb" . }}
+    <li class="breadcrumb-item">
+      <a href="{{ .RelPermalink }}">
+        {{ if .IsHome }}
+          {{ (i18n "home" | default "Home") | emojify }}
+        {{ else }}
+          {{ .LinkTitle | emojify }}
+        {{ end }}
+      </a>
+    </li>
+  {{ end }}
+{{ end }}

+ 0 - 12
wowchemy/layouts/partials/components/breadcrumb_child.html

@@ -1,12 +0,0 @@
-{{ with .Parent }}
-  {{ partial "components/breadcrumb_child" . }}
-  <li class="breadcrumb-item">
-    <a href="{{ .RelPermalink }}">
-      {{ if .IsHome }}
-        {{ (i18n "home" | default "Home") | emojify }}
-      {{ else }}
-        {{ .LinkTitle | emojify }}
-      {{ end }}
-    </a>
-  </li>
-{{ end }}

+ 166 - 164
wowchemy/layouts/partials/navbar.html

@@ -13,12 +13,34 @@
   {{ $logo = (partial "functions/get_logo" (dict "constraint" "max_height" "size" 70)) }}
 {{ end }}
 
-<nav class="navbar navbar-expand-lg navbar-light compensate-for-scrollbar" id="navbar-main">
-  <div class="container-xl">
+<header class="header--fixed">
+  <nav class="navbar navbar-expand-lg navbar-light compensate-for-scrollbar" id="navbar-main">
+    <div class="container-xl">
+
+      {{if $show_logo}}
+      <div class="d-none d-lg-inline-flex">
+        <a class="navbar-brand" href="{{ "/" | relLangURL }}">
+          {{- if $has_logo -}}
+            <img src="{{ $logo.RelPermalink }}" alt="{{ site.Title }}"
+            {{with site.Params.header.image.width}}width="{{.}}"{{end}}
+            {{with site.Params.header.image.height}}height="{{.}}"{{end}}>
+          {{- else -}}
+            {{- site.Title -}}
+          {{- end -}}
+        </a>
+      </div>
+      {{end}}
+
+      {{ if site.Menus.main }}
+      <button type="button" class="navbar-toggler" data-toggle="collapse"
+              data-target="#navbar-content" aria-controls="navbar-content" aria-expanded="false" aria-label="{{ i18n "toggle_navigation" }}">
+      <span><i class="fas fa-bars"></i></span>
+      </button>
+      {{ end }}
 
-    {{if $show_logo}}
-    <div class="d-none d-lg-inline-flex">
-      <a class="navbar-brand" href="{{ "/" | relLangURL }}">
+      {{if $show_logo}}
+      <div class="navbar-brand-mobile-wrapper d-inline-flex d-lg-none">
+        <a class="navbar-brand" href="{{ "/" | relLangURL }}">
         {{- if $has_logo -}}
           <img src="{{ $logo.RelPermalink }}" alt="{{ site.Title }}"
           {{with site.Params.header.image.width}}width="{{.}}"{{end}}
@@ -26,188 +48,168 @@
         {{- else -}}
           {{- site.Title -}}
         {{- end -}}
-      </a>
-    </div>
-    {{end}}
-
-    {{ if site.Menus.main }}
-    <button type="button" class="navbar-toggler" data-toggle="collapse"
-            data-target="#navbar-content" aria-controls="navbar-content" aria-expanded="false" aria-label="{{ i18n "toggle_navigation" }}">
-    <span><i class="fas fa-bars"></i></span>
-    </button>
-    {{ end }}
-
-    {{if $show_logo}}
-    <div class="navbar-brand-mobile-wrapper d-inline-flex d-lg-none">
-      <a class="navbar-brand" href="{{ "/" | relLangURL }}">
-      {{- if $has_logo -}}
-        <img src="{{ $logo.RelPermalink }}" alt="{{ site.Title }}"
-        {{with site.Params.header.image.width}}width="{{.}}"{{end}}
-        {{with site.Params.header.image.height}}height="{{.}}"{{end}}>
-      {{- else -}}
-        {{- site.Title -}}
-      {{- end -}}
-      </a>
-    </div>
-    {{end}}
-
-    <!-- Collect the nav links, forms, and other content for toggling -->
-    {{ $align_menu := site.Params.main_menu.align | default "l" }}
-    <div class="navbar-collapse main-menu-item collapse {{ if eq $align_menu "c" }}justify-content-center{{ else if eq $align_menu "r" }}justify-content-end{{else}}justify-content-start{{ end }}" id="navbar-content">
-
-      <!-- Left Nav Bar -->
-      <ul class="navbar-nav d-md-inline-flex">
-        {{ range site.Menus.main }}
-
-        {{ if .HasChildren }}
-        <li class="nav-item dropdown">
-          <a href="#" class="nav-link dropdown-toggle" data-toggle="dropdown" aria-haspopup="true">
-            {{- .Pre -}}<span>{{ .Name | safeHTML }}</span>{{- .Post -}}
-            <span class="caret"></span>
-          </a>
-          <div class="dropdown-menu">
-            {{ range .Children }}
-              <a class="dropdown-item" href="{{ .URL | relLangURL }}"{{ if $.IsHome }} data-target="{{ .URL }}"{{ end }}>
-                {{- .Pre -}}<span>{{ .Name | safeHTML }}</span>{{- .Post -}}
-              </a>
-            {{ end }}
-          </div>
-        </li>
+        </a>
+      </div>
+      {{end}}
+
+      <!-- Collect the nav links, forms, and other content for toggling -->
+      {{ $align_menu := site.Params.main_menu.align | default "l" }}
+      <div class="navbar-collapse main-menu-item collapse {{ if eq $align_menu "c" }}justify-content-center{{ else if eq $align_menu "r" }}justify-content-end{{else}}justify-content-start{{ end }}" id="navbar-content">
+
+        <!-- Left Nav Bar -->
+        <ul class="navbar-nav d-md-inline-flex">
+          {{ range site.Menus.main }}
+
+          {{ if .HasChildren }}
+          <li class="nav-item dropdown">
+            <a href="#" class="nav-link dropdown-toggle" data-toggle="dropdown" aria-haspopup="true">
+              {{- .Pre -}}<span>{{ .Name | safeHTML }}</span>{{- .Post -}}
+              <span class="caret"></span>
+            </a>
+            <div class="dropdown-menu">
+              {{ range .Children }}
+                <a class="dropdown-item" href="{{ .URL | relLangURL }}"{{ if $.IsHome }} data-target="{{ .URL }}"{{ end }}>
+                  {{- .Pre -}}<span>{{ .Name | safeHTML }}</span>{{- .Post -}}
+                </a>
+              {{ end }}
+            </div>
+          </li>
 
-        {{ else }}
+          {{ else }}
 
-        {{/* Set target for link. */}}
-        {{ $.Scratch.Set "target" "" }}
-        {{ if gt (len .URL) 4 }}
-          {{ if eq "http" (slicestr .URL 0 4) }}
-            {{ $.Scratch.Set "target" " target=\"_blank\" rel=\"noopener\"" }}
+          {{/* Set target for link. */}}
+          {{ $.Scratch.Set "target" "" }}
+          {{ if gt (len .URL) 4 }}
+            {{ if eq "http" (slicestr .URL 0 4) }}
+              {{ $.Scratch.Set "target" " target=\"_blank\" rel=\"noopener\"" }}
+            {{ end }}
           {{ end }}
-        {{ end }}
 
-        {{/* Get active page. */}}
+          {{/* Get active page. */}}
+
+          {{ $is_link_in_current_path := false }}
+          {{ $is_widget_page := or $current_page.IsHome (eq $current_page.Type "widget_page") }}
+          {{ $is_same_page := false }}
+          {{ $hash := findRE "#(.+)" .URL }}
+
+          {{ if $current_page.IsHome | and (or (eq .URL "/") (eq .URL "")) }}
+            {{ $is_link_in_current_path = true }}
+          {{else}}
+            {{ if gt (len .URL) 1 }}{{/* Ignore root URL */}}
+              {{ $is_link_in_current_path = in $current_page.RelPermalink .URL }}
+              {{ $is_same_page = $is_link_in_current_path }}
+            {{end}}
+            {{ if gt (len $hash) 0 }}
+              {{ $hash = index $hash 0 }}
+              {{ $hash_removed := replace .URL $hash "" }}
+              {{ if eq (len $hash_removed) 0 }}
+                {{ $hash_removed = "/" }}{{/* Add robustness for `/#SECTION` or `#SECTION` in `menus.toml`. */}}
+              {{ end }}
+              {{ $is_same_page = eq (path.Dir $current_page.RelPermalink) (path.Dir ($hash_removed|relLangURL)) }}
+            {{ end }}
+          {{end}}
 
-        {{ $is_link_in_current_path := false }}
-        {{ $is_widget_page := or $current_page.IsHome (eq $current_page.Type "widget_page") }}
-        {{ $is_same_page := false }}
-        {{ $hash := findRE "#(.+)" .URL }}
+          <li class="nav-item">
+            <a class="nav-link {{if and $highlight_active_link $is_link_in_current_path }} active{{end}}" href="{{.URL | relLangURL}}"{{ if and $is_widget_page $is_same_page }} data-target="{{$hash}}"{{ end }}{{ ($.Scratch.Get "target") | safeHTMLAttr }}>
+              {{- .Pre -}}<span>{{ .Name | safeHTML }}</span>{{- .Post -}}
+            </a>
+          </li>
 
-        {{ if $current_page.IsHome | and (or (eq .URL "/") (eq .URL "")) }}
-          {{ $is_link_in_current_path = true }}
-        {{else}}
-          {{ if gt (len .URL) 1 }}{{/* Ignore root URL */}}
-            {{ $is_link_in_current_path = in $current_page.RelPermalink .URL }}
-            {{ $is_same_page = $is_link_in_current_path }}
-          {{end}}
-          {{ if gt (len $hash) 0 }}
-            {{ $hash = index $hash 0 }}
-            {{ $hash_removed := replace .URL $hash "" }}
-            {{ if eq (len $hash_removed) 0 }}
-              {{ $hash_removed = "/" }}{{/* Add robustness for `/#SECTION` or `#SECTION` in `menus.toml`. */}}
-            {{ end }}
-            {{ $is_same_page = eq (path.Dir $current_page.RelPermalink) (path.Dir ($hash_removed|relLangURL)) }}
           {{ end }}
-        {{end}}
-
-        <li class="nav-item">
-          <a class="nav-link {{if and $highlight_active_link $is_link_in_current_path }} active{{end}}" href="{{.URL | relLangURL}}"{{ if and $is_widget_page $is_same_page }} data-target="{{$hash}}"{{ end }}{{ ($.Scratch.Get "target") | safeHTMLAttr }}>
-            {{- .Pre -}}<span>{{ .Name | safeHTML }}</span>{{- .Post -}}
-          </a>
-        </li>
+          {{ end }}
 
-        {{ end }}
+        {{ if site.Menus.main_right | and (eq $align_menu "l") }}
+        </ul>
+        <ul class="navbar-nav ml-md-auto">
         {{ end }}
 
-      {{ if site.Menus.main_right | and (eq $align_menu "l") }}
-      </ul>
-      <ul class="navbar-nav ml-md-auto">
-      {{ end }}
+          {{ range site.Menus.main_right }}
 
-        {{ range site.Menus.main_right }}
+          {{/* Set target for link. */}}
+          {{ $.Scratch.Set "target" "" }}
+          {{ if gt (len .URL) 4 }}
+          {{ if eq "http" (slicestr .URL 0 4) }}
+          {{ $.Scratch.Set "target" " target=\"_blank\" rel=\"noopener\"" }}
+          {{ end }}
+          {{ end }}
 
-        {{/* Set target for link. */}}
-        {{ $.Scratch.Set "target" "" }}
-        {{ if gt (len .URL) 4 }}
-        {{ if eq "http" (slicestr .URL 0 4) }}
-        {{ $.Scratch.Set "target" " target=\"_blank\" rel=\"noopener\"" }}
-        {{ end }}
+          <li class="nav-item">
+            <a class="nav-link" href="{{ .URL | relLangURL }}"{{ if $.IsHome }} data-target="{{ .URL }}"{{ end }}{{ ($.Scratch.Get "target") | safeHTMLAttr }}>
+              {{- .Pre -}}<span>{{ .Name | safeHTML }}</span>{{- .Post -}}
+            </a>
+          </li>
+
+          {{ end }}
+        </ul>
+      </div><!-- /.navbar-collapse -->
+
+      <ul class="nav-icons navbar-nav flex-row ml-auto d-flex pl-md-2">
+
+        {{/* Display any social links that the superuser chose to display in the header. */}}
+        {{ range where (where (where site.Pages "Section" "authors") ".Params.superuser" true) ".Params.social" "!=" nil }}
+          {{ range where .Params.social ".display.header" true }}
+            {{ $social_link := partial "functions/get_social_link" . }}
+            <li class="nav-item d-none d-lg-inline-flex">
+              <a class="nav-link" href="{{ $social_link.link | safeURL }}"{{ with $social_link.tooltip }} data-toggle="tooltip" data-placement="bottom" title="{{.}}"{{ end }} {{ $social_link.target | safeHTMLAttr }} aria-label="{{ $social_link.aria_label }}">
+                <i class="{{ $social_link.icon_pack }} {{ $social_link.pack_prefix }}-{{ $social_link.icon }}" aria-hidden="true"></i>
+              </a>
+            </li>
+          {{ end }}
         {{ end }}
 
+        {{ $show_search := site.Params.main_menu.show_search | default true }}
+        {{ if and site.Params.search.provider $show_search }}
         <li class="nav-item">
-          <a class="nav-link" href="{{ .URL | relLangURL }}"{{ if $.IsHome }} data-target="{{ .URL }}"{{ end }}{{ ($.Scratch.Get "target") | safeHTMLAttr }}>
-            {{- .Pre -}}<span>{{ .Name | safeHTML }}</span>{{- .Post -}}
-          </a>
+          <a class="nav-link js-search" href="#" aria-label="{{ i18n "search" }}"><i class="fas fa-search" aria-hidden="true"></i></a>
         </li>
-
         {{ end }}
-      </ul>
-    </div><!-- /.navbar-collapse -->
 
-    <ul class="nav-icons navbar-nav flex-row ml-auto d-flex pl-md-2">
-
-      {{/* Display any social links that the superuser chose to display in the header. */}}
-      {{ range where (where (where site.Pages "Section" "authors") ".Params.superuser" true) ".Params.social" "!=" nil }}
-        {{ range where .Params.social ".display.header" true }}
-          {{ $social_link := partial "functions/get_social_link" . }}
-          <li class="nav-item d-none d-lg-inline-flex">
-            <a class="nav-link" href="{{ $social_link.link | safeURL }}"{{ with $social_link.tooltip }} data-toggle="tooltip" data-placement="bottom" title="{{.}}"{{ end }} {{ $social_link.target | safeHTMLAttr }} aria-label="{{ $social_link.aria_label }}">
-              <i class="{{ $social_link.icon_pack }} {{ $social_link.pack_prefix }}-{{ $social_link.icon }}" aria-hidden="true"></i>
+        {{ $show_day_night := site.Params.main_menu.show_day_night | default true }}
+        {{ if and site.Params.day_night $show_day_night }}
+        <li class="nav-item dropdown theme-dropdown">
+          <a href="#" class="nav-link" data-toggle="dropdown" aria-haspopup="true" aria-label="{{ i18n "theme_selector" | default "Display preferences" }}">
+            <i class="fas fa-moon" aria-hidden="true"></i>
+          </a>
+          <div class="dropdown-menu">
+            <a href="#" class="dropdown-item js-set-theme-light">
+              <span>{{ i18n "theme_light" | default "Light" }}</span>
             </a>
-          </li>
+            <a href="#" class="dropdown-item js-set-theme-dark">
+              <span>{{ i18n "theme_dark" | default "Dark" }}</span>
+            </a>
+            <a href="#" class="dropdown-item js-set-theme-auto">
+              <span>{{ i18n "theme_auto" | default "Automatic" }}</span>
+            </a>
+          </div>
+        </li>
         {{ end }}
-      {{ end }}
-
-      {{ $show_search := site.Params.main_menu.show_search | default true }}
-      {{ if and site.Params.search.provider $show_search }}
-      <li class="nav-item">
-        <a class="nav-link js-search" href="#" aria-label="{{ i18n "search" }}"><i class="fas fa-search" aria-hidden="true"></i></a>
-      </li>
-      {{ end }}
 
-      {{ $show_day_night := site.Params.main_menu.show_day_night | default true }}
-      {{ if and site.Params.day_night $show_day_night }}
-      <li class="nav-item dropdown theme-dropdown">
-        <a href="#" class="nav-link" data-toggle="dropdown" aria-haspopup="true" aria-label="{{ i18n "theme_selector" | default "Display preferences" }}">
-          <i class="fas fa-moon" aria-hidden="true"></i>
-        </a>
-        <div class="dropdown-menu">
-          <a href="#" class="dropdown-item js-set-theme-light">
-            <span>{{ i18n "theme_light" | default "Light" }}</span>
-          </a>
-          <a href="#" class="dropdown-item js-set-theme-dark">
-            <span>{{ i18n "theme_dark" | default "Dark" }}</span>
+        {{ $show_translations := site.Params.main_menu.show_translations | default true }}
+        {{ if .IsTranslated | and $show_translations }}
+        <li class="nav-item dropdown i18n-dropdown">
+          <a href="#" class="nav-link {{ if $show_current_language }}dropdown-toggle{{end}}" data-toggle="dropdown"
+             aria-haspopup="true" aria-label="{{ i18n "languages" | default "Languages" }}">
+            <i class="fas fa-globe mr-1" aria-hidden="true"></i>
+            {{- if $show_current_language -}}
+              <span class="d-none d-lg-inline">{{ index site.Data.i18n.languages .Lang }}</span>
+            {{- end -}}
           </a>
-          <a href="#" class="dropdown-item js-set-theme-auto">
-            <span>{{ i18n "theme_auto" | default "Automatic" }}</span>
-          </a>
-        </div>
-      </li>
-      {{ end }}
-
-      {{ $show_translations := site.Params.main_menu.show_translations | default true }}
-      {{ if .IsTranslated | and $show_translations }}
-      <li class="nav-item dropdown i18n-dropdown">
-        <a href="#" class="nav-link {{ if $show_current_language }}dropdown-toggle{{end}}" data-toggle="dropdown"
-           aria-haspopup="true" aria-label="{{ i18n "languages" | default "Languages" }}">
-          <i class="fas fa-globe mr-1" aria-hidden="true"></i>
-          {{- if $show_current_language -}}
-            <span class="d-none d-lg-inline">{{ index site.Data.i18n.languages .Lang }}</span>
-          {{- end -}}
-        </a>
-        <div class="dropdown-menu">
-          <div class="dropdown-item dropdown-item-active">
-            <span>{{ index site.Data.i18n.languages .Lang }}</span>
+          <div class="dropdown-menu">
+            <div class="dropdown-item dropdown-item-active">
+              <span>{{ index site.Data.i18n.languages .Lang }}</span>
+            </div>
+            {{ range .Translations }}
+            <a class="dropdown-item" href="{{ .Permalink }}"{{ if $.IsHome }} data-target="{{ .RelPermalink }}"{{ end }}>
+              <span>{{ index site.Data.i18n.languages .Lang }}</span>
+            </a>
+            {{ end }}
           </div>
-          {{ range .Translations }}
-          <a class="dropdown-item" href="{{ .Permalink }}"{{ if $.IsHome }} data-target="{{ .RelPermalink }}"{{ end }}>
-            <span>{{ index site.Data.i18n.languages .Lang }}</span>
-          </a>
-          {{ end }}
-        </div>
-      </li>
-      {{ end }}
+        </li>
+        {{ end }}
 
-    </ul>
+      </ul>
 
-  </div><!-- /.container -->
-</nav>
+    </div><!-- /.container -->
+  </nav>
+</header>
 {{end}}{{/* End show navbar. */}}

+ 14 - 0
wowchemy/layouts/partials/site_js.html

@@ -131,6 +131,20 @@
     <script src="{{ $js_algolia_search.RelPermalink }}" type="module"></script>
     {{ end }}
 
+    {{/* Page Data */}}
+    {{ $default_headroom := not (.IsHome | or (eq .Type "book")) }}
+    {{ $use_headroom := cond (isset $.Params "header.on_scroll") (eq $.Params.header.on_scroll "disappear") (default $default_headroom) }}
+    {{ printf "<script id=\"page-data\" type=\"application/json\">%s</script>" (dict "use_headroom" $use_headroom | jsonify) | safeHTML}}
+
+    {{/* Headroom */}}
+    {{ if $use_headroom }}
+      {{ $headroom := resources.Get "js/wowchemy-headroom.js" | js.Build (dict "format" "esm" "minify" true) }}
+      {{- if hugo.IsProduction -}}
+        {{- $headroom = $headroom | fingerprint "md5" -}}
+      {{- end -}}
+      <script src="{{ $headroom.RelPermalink }}" type="module"></script>
+    {{- end -}}
+
     {{ $js_license := printf "/*! Wowchemy v%s | https://wowchemy.com/ */\n" site.Data.wowchemy.version }}
     {{ $js_license := $js_license | printf "%s/*! Copyright 2016-present George Cushen (https://georgecushen.com/) */\n" }}
     {{ $js_license := $js_license | printf "%s/*! License: https://github.com/wowchemy/wowchemy-hugo-themes/blob/main/LICENSE.md */\n" }}

+ 5 - 0
yarn.lock

@@ -962,6 +962,11 @@ has@^1.0.3:
   dependencies:
     function-bind "^1.1.1"
 
+headroom.js@^0.12.0:
+  version "0.12.0"
+  resolved "https://registry.yarnpkg.com/headroom.js/-/headroom.js-0.12.0.tgz#e09b466b18d22457f2023fb946ff620e47a5c205"
+  integrity sha512-iXnAafUm3FdzfJ91uixLws2hkKI1jC8bAKK/pt7XYr8Ie1jO7xbK48Ycpl9tUPyBgkzuj1p/PhJS0fy4E/5anA==
+
 hosted-git-info@^2.1.4:
   version "2.8.8"
   resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.8.8.tgz#7539bd4bc1e0e0a895815a2e0262420b12858488"

Some files were not shown because too many files changed in this diff