mirror of
https://github.com/tiennm99/HugoBlox-kit.git
synced 2026-10-12 16:15:12 +00:00
feat: add support for Headroom
When header.on_scroll == "disappear", with sensible defaults
This commit is contained in:
1 parent
8ff1659261
commit
994d21b3dd
10 files changed
+258
-190
No files matched your search
@@ -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"
|
||||
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
/*!
|
||||
* headroom.js v0.12.0 - Give your page some headroom. Hide your header until you need it
|
||||
* Copyright (c) 2020 Nick Williams - http://wicky.nillia.ms/headroom.js
|
||||
* License: MIT
|
||||
*/
|
||||
|
||||
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(t=t||self).Headroom=n()}(this,function(){"use strict";function t(){return"undefined"!=typeof window}function d(t){return function(t){return t&&t.document&&function(t){return 9===t.nodeType}(t.document)}(t)?function(t){var n=t.document,o=n.body,s=n.documentElement;return{scrollHeight:function(){return Math.max(o.scrollHeight,s.scrollHeight,o.offsetHeight,s.offsetHeight,o.clientHeight,s.clientHeight)},height:function(){return t.innerHeight||s.clientHeight||o.clientHeight},scrollY:function(){return void 0!==t.pageYOffset?t.pageYOffset:(s||o.parentNode||o).scrollTop}}}(t):function(t){return{scrollHeight:function(){return Math.max(t.scrollHeight,t.offsetHeight,t.clientHeight)},height:function(){return Math.max(t.offsetHeight,t.clientHeight)},scrollY:function(){return t.scrollTop}}}(t)}function n(t,s,e){var n,o=function(){var n=!1;try{var t={get passive(){n=!0}};window.addEventListener("test",t,t),window.removeEventListener("test",t,t)}catch(t){n=!1}return n}(),i=!1,r=d(t),l=r.scrollY(),a={};function c(){var t=Math.round(r.scrollY()),n=r.height(),o=r.scrollHeight();a.scrollY=t,a.lastScrollY=l,a.direction=l<t?"down":"up",a.distance=Math.abs(t-l),a.isOutOfBounds=t<0||o<t+n,a.top=t<=s.offset[a.direction],a.bottom=o<=t+n,a.toleranceExceeded=a.distance>s.tolerance[a.direction],e(a),l=t,i=!1}function h(){i||(i=!0,n=requestAnimationFrame(c))}var u=!!o&&{passive:!0,capture:!1};return t.addEventListener("scroll",h,u),c(),{destroy:function(){cancelAnimationFrame(n),t.removeEventListener("scroll",h,u)}}}function o(t){return t===Object(t)?t:{down:t,up:t}}function s(t,n){n=n||{},Object.assign(this,s.options,n),this.classes=Object.assign({},s.options.classes,n.classes),this.elem=t,this.tolerance=o(this.tolerance),this.offset=o(this.offset),this.initialised=!1,this.frozen=!1}return s.prototype={constructor:s,init:function(){return s.cutsTheMustard&&!this.initialised&&(this.addClass("initial"),this.initialised=!0,setTimeout(function(t){t.scrollTracker=n(t.scroller,{offset:t.offset,tolerance:t.tolerance},t.update.bind(t))},100,this)),this},destroy:function(){this.initialised=!1,Object.keys(this.classes).forEach(this.removeClass,this),this.scrollTracker.destroy()},unpin:function(){!this.hasClass("pinned")&&this.hasClass("unpinned")||(this.addClass("unpinned"),this.removeClass("pinned"),this.onUnpin&&this.onUnpin.call(this))},pin:function(){this.hasClass("unpinned")&&(this.addClass("pinned"),this.removeClass("unpinned"),this.onPin&&this.onPin.call(this))},freeze:function(){this.frozen=!0,this.addClass("frozen")},unfreeze:function(){this.frozen=!1,this.removeClass("frozen")},top:function(){this.hasClass("top")||(this.addClass("top"),this.removeClass("notTop"),this.onTop&&this.onTop.call(this))},notTop:function(){this.hasClass("notTop")||(this.addClass("notTop"),this.removeClass("top"),this.onNotTop&&this.onNotTop.call(this))},bottom:function(){this.hasClass("bottom")||(this.addClass("bottom"),this.removeClass("notBottom"),this.onBottom&&this.onBottom.call(this))},notBottom:function(){this.hasClass("notBottom")||(this.addClass("notBottom"),this.removeClass("bottom"),this.onNotBottom&&this.onNotBottom.call(this))},shouldUnpin:function(t){return"down"===t.direction&&!t.top&&t.toleranceExceeded},shouldPin:function(t){return"up"===t.direction&&t.toleranceExceeded||t.top},addClass:function(t){this.elem.classList.add.apply(this.elem.classList,this.classes[t].split(" "))},removeClass:function(t){this.elem.classList.remove.apply(this.elem.classList,this.classes[t].split(" "))},hasClass:function(t){return this.classes[t].split(" ").every(function(t){return this.classList.contains(t)},this.elem)},update:function(t){t.isOutOfBounds||!0!==this.frozen&&(t.top?this.top():this.notTop(),t.bottom?this.bottom():this.notBottom(),this.shouldUnpin(t)?this.unpin():this.shouldPin(t)&&this.pin())}},s.options={tolerance:{up:0,down:0},offset:0,scroller:t()?window:null,classes:{frozen:"headroom--frozen",pinned:"headroom--pinned",unpinned:"headroom--unpinned",top:"headroom--top",notTop:"headroom--not-top",bottom:"headroom--bottom",notBottom:"headroom--not-bottom",initial:"headroom"}},s.cutsTheMustard=!!(t()&&function(){}.bind&&"classList"in document.documentElement&&Object.assign&&Object.keys&&requestAnimationFrame),s});
|
||||
@@ -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();
|
||||
});
|
||||
}
|
||||
@@ -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.
|
||||
|
||||
@@ -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 -}}
|
||||
|
||||
@@ -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 }}
|
||||
@@ -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 }}
|
||||
@@ -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 $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="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}}
|
||||
</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 }}
|
||||
<!-- 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">
|
||||
|
||||
{{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}}
|
||||
<!-- Left Nav Bar -->
|
||||
<ul class="navbar-nav d-md-inline-flex">
|
||||
{{ range site.Menus.main }}
|
||||
|
||||
<!-- 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">
|
||||
{{ 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>
|
||||
|
||||
<!-- Left Nav Bar -->
|
||||
<ul class="navbar-nav d-md-inline-flex">
|
||||
{{ range site.Menus.main }}
|
||||
{{ else }}
|
||||
|
||||
{{ 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>
|
||||
{{/* 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 }}
|
||||
</div>
|
||||
</li>
|
||||
|
||||
{{ 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\"" }}
|
||||
{{ 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 }}
|
||||
{{ $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 }}
|
||||
{{ 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}}
|
||||
{{ 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 }}
|
||||
|
||||
{{ 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 }}
|
||||
|
||||
<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>
|
||||
<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 }}
|
||||
|
||||
{{ $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>
|
||||
</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>
|
||||
{{ 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 }}
|
||||
{{ end }}
|
||||
|
||||
</ul>
|
||||
{{ if site.Menus.main_right | and (eq $align_menu "l") }}
|
||||
</ul>
|
||||
<ul class="navbar-nav ml-md-auto">
|
||||
{{ end }}
|
||||
|
||||
</div><!-- /.container -->
|
||||
</nav>
|
||||
{{ 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 }}
|
||||
|
||||
<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 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>
|
||||
</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>
|
||||
{{ 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 }}
|
||||
|
||||
</ul>
|
||||
|
||||
</div><!-- /.container -->
|
||||
</nav>
|
||||
</header>
|
||||
{{end}}{{/* End show navbar. */}}
|
||||
@@ -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" }}
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in new issue
Block a user