Compare commits

...

18 Commits

Author SHA1 Message Date
Mark Dumay
9d59c0ba0d Merge pull request #774 from gethinode/develop
Refactor download button
2024-02-15 05:50:58 +01:00
Mark Dumay
22bfb75c82 Merge branch 'main' into develop 2024-02-15 05:39:03 +01:00
Mark Dumay
2b9a0aa085 Merge pull request #773 from gethinode/hugo-mod-dependencies
Update Hugo module dependencies
2024-02-15 05:38:04 +01:00
Mark Dumay
d36c70b98e Refactor download button 2024-02-15 05:37:36 +01:00
markdumay
941c0f4954 fix: update Hugo module dependencies 2024-02-15 03:18:23 +00:00
Mark Dumay
94867de265 Merge pull request #772 from gethinode/develop
Improve rendering of TOC dropdown
2024-02-14 06:12:55 +01:00
Mark Dumay
02d4aafd10 Merge branch 'main' into develop 2024-02-14 06:07:59 +01:00
Mark Dumay
fcb64b9e77 Bump package release 2024-02-14 06:04:26 +01:00
Mark Dumay
ed764e14f5 Improve rendering of TOC dropdown 2024-02-14 06:03:35 +01:00
Mark Dumay
0b20d24918 Merge pull request #771 from gethinode/develop
Support preloading of local font
2024-02-13 05:05:35 +01:00
Mark Dumay
00ef30b768 Merge branch 'main' into develop 2024-02-13 04:55:56 +01:00
Mark Dumay
cb6402ac92 Support preloading of local font 2024-02-13 04:55:19 +01:00
Mark Dumay
89758426a9 Merge pull request #770 from deining/dependabot-github-actions
dependabot: check for updates to GitHub actions
2024-02-13 04:18:28 +01:00
Andreas Deininger
d48c6ab314 dependabot: check for updates to GitHub actions 2024-02-12 20:22:45 +01:00
Mark Dumay
aa5e6c6189 Merge pull request #766 from gethinode/develop
Fix navbar on reload and include version data
2024-02-11 12:08:54 +01:00
Mark Dumay
5bf7712307 Merge branch 'main' into develop 2024-02-11 11:56:23 +01:00
Mark Dumay
ddb847c974 Include Hinode version in metadata 2024-02-11 11:22:29 +01:00
Mark Dumay
9e52107dbf Fix navbar style on page reloads and theme updates 2024-02-11 08:28:16 +01:00
15 changed files with 119 additions and 48 deletions

View File

@@ -3,6 +3,11 @@
version: 2 version: 2
updates: updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
open-pull-requests-limit: 10
- package-ecosystem: "npm" - package-ecosystem: "npm"
directory: "/" directory: "/"
schedule: schedule:

View File

@@ -3,14 +3,7 @@ const togglers = document.querySelectorAll('.main-nav-toggler')
const modeSelectors = document.querySelectorAll('.switch-mode-collapsed') const modeSelectors = document.querySelectorAll('.switch-mode-collapsed')
const colorsBG = ['body', 'secondary', 'tertiary'] const colorsBG = ['body', 'secondary', 'tertiary']
if (navbar !== null && togglers !== null) { function updateNavbar () {
// initialize background color
const color = (navbar.getAttribute('data-navbar-color') || 'body')
const bg = colorsBG.includes(color) ? `var(--bs-${color}-bg)` : `var(--bs-navbar-color-${color})`
navbar.style.setProperty('--bs-navbar-expanded-color', bg)
// set the navbar background color to opaque when scrolling past a breakpoint
window.onscroll = () => {
if (window.scrollY > 75) { if (window.scrollY > 75) {
navbar.classList.add('nav-active') navbar.classList.add('nav-active')
const storedTheme = localStorage.getItem('theme') const storedTheme = localStorage.getItem('theme')
@@ -22,6 +15,34 @@ if (navbar !== null && togglers !== null) {
} }
} }
if ((navbar !== null) && (window.performance.getEntriesByType)) {
if (window.performance.getEntriesByType('navigation')[0].type === 'reload') {
updateNavbar()
}
}
if (navbar !== null && togglers !== null) {
// observe state changes to the site's color mode
const html = document.querySelector('html')
const config = {
attributes: true,
attributeFilter: ['data-bs-theme']
}
const Observer = new MutationObserver((mutationrecords) => {
updateNavbar()
})
Observer.observe(html, config)
// initialize background color
const color = (navbar.getAttribute('data-navbar-color') || 'body')
const bg = colorsBG.includes(color) ? `var(--bs-${color}-bg)` : `var(--bs-navbar-color-${color})`
navbar.style.setProperty('--bs-navbar-expanded-color', bg)
// set the navbar background color to opaque when scrolling past a breakpoint
window.onscroll = () => {
updateNavbar()
}
// set the navbar background color to opaque when expanded // set the navbar background color to opaque when expanded
for (let i = 0; i < togglers.length; ++i) { for (let i = 0; i < togglers.length; ++i) {
togglers[i].onclick = () => { togglers[i].onclick = () => {

View File

@@ -50,6 +50,9 @@
#toc-collapse { #toc-collapse {
border-color: var(--bs-secondary-color) !important; border-color: var(--bs-secondary-color) !important;
border-radius: 0 0 var(--bs-border-radius) var(--bs-border-radius) !important;
margin-top: -1.5rem;
padding-top: 1.5rem !important;
} }
.toc-button { .toc-button {
@@ -60,6 +63,8 @@
--bs-btn-active-bg: var(--bs-body-bg); --bs-btn-active-bg: var(--bs-body-bg);
--bs-btn-active-border-color: var(--bs-primary); --bs-btn-active-border-color: var(--bs-primary);
background-color: var(--#{$prefix}body-bg) !important;
&.active, &.active,
&:hover, &:hover,
&:focus { &:focus {

View File

@@ -162,6 +162,7 @@
themeFont = "Inter" themeFont = "Inter"
# themeFontPath = "https://fonts.googleapis.com/css2?family=Inter:wght@200;300;600&display=swap" # external path # themeFontPath = "https://fonts.googleapis.com/css2?family=Inter:wght@200;300;600&display=swap" # external path
themeFontPath = "/fonts" # local path themeFontPath = "/fonts" # local path
themeFontPreload = "/fonts/inter-v12-latin-regular.woff2"
fontSizeBase = "1rem" # assumes the browser default, typically '16px' fontSizeBase = "1rem" # assumes the browser default, typically '16px'
# toml-docs-end font # toml-docs-end font
# toml-docs-start build # toml-docs-start build

View File

@@ -157,6 +157,7 @@
themeFont = "Inter" themeFont = "Inter"
# themeFontPath = "https://fonts.googleapis.com/css2?family=Inter:wght@200;300;600&display=swap" # external path # themeFontPath = "https://fonts.googleapis.com/css2?family=Inter:wght@200;300;600&display=swap" # external path
themeFontPath = "/fonts" # local path themeFontPath = "/fonts" # local path
themeFontPreload = "/fonts/inter-v12-latin-regular.woff2"
purge = true purge = true
# toml-docs-end theme-colors # toml-docs-end theme-colors

2
go.mod
View File

@@ -10,7 +10,7 @@ require (
github.com/gethinode/mod-katex v1.0.5 // indirect github.com/gethinode/mod-katex v1.0.5 // indirect
github.com/gethinode/mod-leaflet v1.0.0 // indirect github.com/gethinode/mod-leaflet v1.0.0 // indirect
github.com/gethinode/mod-lottie v1.4.2 // indirect github.com/gethinode/mod-lottie v1.4.2 // indirect
github.com/gethinode/mod-utils/v2 v2.0.3 // indirect github.com/gethinode/mod-utils/v2 v2.1.0 // indirect
github.com/nextapps-de/flexsearch v0.0.0-20240110101704-4c3966709f85 // indirect github.com/nextapps-de/flexsearch v0.0.0-20240110101704-4c3966709f85 // indirect
github.com/twbs/bootstrap v5.3.2+incompatible // indirect github.com/twbs/bootstrap v5.3.2+incompatible // indirect
) )

2
go.sum
View File

@@ -144,6 +144,8 @@ github.com/gethinode/mod-utils/v2 v2.0.2 h1:pocFT/mWPcfmABltZwe76D1IB3TZIrD1k1kH
github.com/gethinode/mod-utils/v2 v2.0.2/go.mod h1:GTYeknoLujNjfDxI+V9Dcug26CYJSTJ0B/U2dagw9oY= github.com/gethinode/mod-utils/v2 v2.0.2/go.mod h1:GTYeknoLujNjfDxI+V9Dcug26CYJSTJ0B/U2dagw9oY=
github.com/gethinode/mod-utils/v2 v2.0.3 h1:4BsRNGi+0a3Mq021Gq/TwDNiyuIfZ8xnpYU0DkNbUYI= github.com/gethinode/mod-utils/v2 v2.0.3 h1:4BsRNGi+0a3Mq021Gq/TwDNiyuIfZ8xnpYU0DkNbUYI=
github.com/gethinode/mod-utils/v2 v2.0.3/go.mod h1:GTYeknoLujNjfDxI+V9Dcug26CYJSTJ0B/U2dagw9oY= github.com/gethinode/mod-utils/v2 v2.0.3/go.mod h1:GTYeknoLujNjfDxI+V9Dcug26CYJSTJ0B/U2dagw9oY=
github.com/gethinode/mod-utils/v2 v2.1.0 h1:5I0IN/AX5qPFYx7tjWXk59GBevTJzixxZUGj9MJ0b8M=
github.com/gethinode/mod-utils/v2 v2.1.0/go.mod h1:GTYeknoLujNjfDxI+V9Dcug26CYJSTJ0B/U2dagw9oY=
github.com/nextapps-de/flexsearch v0.0.0-20230711092928-1243fd883ec3 h1:H/qVR5O4BXjRjD+5PZB+r4ug2BSJ2Of4RtwOntd+OKo= github.com/nextapps-de/flexsearch v0.0.0-20230711092928-1243fd883ec3 h1:H/qVR5O4BXjRjD+5PZB+r4ug2BSJ2Of4RtwOntd+OKo=
github.com/nextapps-de/flexsearch v0.0.0-20230711092928-1243fd883ec3/go.mod h1:5GdMfPAXzbA2gXBqTjC6l27kioSYzHlqDMh0+wyx7sU= github.com/nextapps-de/flexsearch v0.0.0-20230711092928-1243fd883ec3/go.mod h1:5GdMfPAXzbA2gXBqTjC6l27kioSYzHlqDMh0+wyx7sU=
github.com/nextapps-de/flexsearch v0.0.0-20240108021025-afd75f742f22 h1:re7L8FxbXQpnX8BgzkdUnDpsUmloGNyLmiy2ZCln8pg= github.com/nextapps-de/flexsearch v0.0.0-20240108021025-afd75f742f22 h1:re7L8FxbXQpnX8BgzkdUnDpsUmloGNyLmiy2ZCln8pg=

View File

@@ -1,17 +1,15 @@
{{- $download := .Params.download -}} {{- $download := .Params.download -}}
{{- if and $download (not (fileExists (path.Join "static" $download))) -}}
{{- errorf "Cannot find download file for page '%s': %s" .File.Path $download -}}
{{- end -}}
{{- $toc := .Site.Params.navigation.toc -}} {{- $includeToc := false -}}
{{ if $toc }} {{- if .Site.Params.navigation.toc -}}
{{ $includeToc = true }}
{{ if isset .Params "includeToc" }} {{ if isset .Params "includeToc" }}
{{ $toc = .Params.includeToc }} {{ $includeToc = .Params.includeToc }}
{{ else }} {{ else }}
{{- with (index site.Params.pages .Type) -}} {{- with (index site.Params.pages .Type) -}}
{{ if isset . "includetoc" }} {{ if isset . "includetoc" }}
{{ $toc = index . "includetoc" }} {{ $includeToc = index . "includetoc" }}
{{ if ne (printf "%T" $toc) "bool" }} {{ if ne (printf "%T" $includeToc) "bool" }}
{{ errorf "Expected bool value in site parameters: pages.%s.includeToc" $.Type }} {{ errorf "Expected bool value in site parameters: pages.%s.includeToc" $.Type }}
{{ end }} {{ end }}
{{ end }} {{ end }}
@@ -19,24 +17,20 @@
{{ end }} {{ end }}
{{ end }} {{ end }}
<div class="toc toc-sidebar mb-5 my-md-0 ps-xl-3 mb-lg-5 p-3 text-body-secondary sticky-top"> <div class="toc toc-sidebar mb-5 my-md-0 mb-lg-5 p-3 text-body-secondary sticky-top">
{{ with $download }} {{ if $download }}
{{ $title := (T "download" ) }} <div class="mb-5 p-0">
{{ $lang := strings.TrimPrefix "." (path.Ext (path.BaseName .)) }} {{ partial "assets/download.html" (dict
{{ if and $lang (ne (string site.LanguageCode) $lang) }} "download" $download
{{ range site.Languages }} "outline" true
{{ if eq .LanguageCode $lang }} "size" "sm"
{{ $title = printf "%s (%s)" (T "download") (T (printf "lang_%s" .LanguageCode)) }} "order" "last"
{{ end }} ) }}
{{ end }}
{{ end }}
<div class="mb-5 text-center">
{{ $attr := dict "download" (path.Base .) }}
{{ partial "assets/button.html" (dict "href" . "title" $title "color" "primary" "outline" "true" "icon" "fas download" "size" "sm" "attributes" $attr) }}
</div> </div>
{{ end }} {{ end }}
{{ if $toc }} {{ if $includeToc }}
{{ partial "assets/toc.html" (dict "page" .) }} {{ $index := partial "assets/toc.html" (dict "page" .) }}
{{ $index | safeHTML }}
{{ end -}} {{ end -}}
</div> </div>

View File

@@ -0,0 +1,38 @@
{{- $download := partial "utilities/GetTargetPath.html" (dict "path" .download "page" page) -}}
{{- $color := .color | default "primary" -}}
{{- $outline := .outline | default true -}}
{{- $icon := .icon | default "fas download" -}}
{{- $size := .size | default "sm" -}}
{{- $justify := .justify -}}
{{- $class := .class -}}
{{- $minimal := .minimal | default false -}}
{{- if and $download (not (fileExists (path.Join "static" $download))) -}}
{{- errorf "Cannot find download file for page '%s': %s" page.File.Path $download -}}
{{- end -}}
{{ with $download }}
{{ $title := "" }}
{{ if not $minimal }}{{ $title = (T "download" ) }}{{ end }}
{{ $lang := strings.TrimPrefix "." (path.Ext (path.BaseName .)) }}
{{ if and $lang (ne (string site.LanguageCode) $lang) }}
{{ range site.Languages }}
{{ if eq .LanguageCode $lang }}
{{ $title = printf "%s (%s)" (T "download") (T (printf "lang_%s" .LanguageCode)) }}
{{ end }}
{{ end }}
{{ end }}
{{ $attr := dict "download" (path.Base .) }}
{{ partial "assets/button.html" (dict
"href" .
"title" $title
"color" $color
"outline" $outline
"icon" $icon
"size" $size
"justify" $justify
"class" $class
"attributes" $attr
) }}
{{ end }}

View File

@@ -35,7 +35,7 @@
{{- $sort := $page.Site.Params.sharing.sort | default "weight" -}} {{- $sort := $page.Site.Params.sharing.sort | default "weight" -}}
{{- $list = sort $list $sort $order -}} {{- $list = sort $list $sort $order -}}
{{- $download := $page.Params.download -}} {{- $download := partial "utilities/GetTargetPath.html" (dict "path" $page.Params.download "page" $page) -}}
{{- if and $download (not (fileExists (path.Join "static" $download))) -}} {{- if and $download (not (fileExists (path.Join "static" $download))) -}}
{{- errorf "Cannot find download file for page '%s': %s" $page.File.Path $download -}} {{- errorf "Cannot find download file for page '%s': %s" $page.File.Path $download -}}
{{- end -}} {{- end -}}

View File

@@ -26,15 +26,14 @@
"icon" "fas sort" "icon" "fas sort"
"justify" "between" "justify" "between"
"collapse" "toc-collapse" "collapse" "toc-collapse"
"order" "last") "order" "last"
-}} "spacing" false
) -}}
</div> </div>
<p>
<div class="collapse border bg-body-tertiary rounded p-1 navbar-nav-scroll" id="toc-collapse"> <div class="collapse border bg-body-tertiary rounded p-1 navbar-nav-scroll" id="toc-collapse">
<div class="toc toc-panel text-body p-2"> <div class="toc toc-panel text-body p-2">
<small>{{ $page.TableOfContents }}</small> <small>{{ $page.TableOfContents }}</small>
</div> </div>
</div> </div>
</p>
{{ end -}} {{ end -}}

View File

@@ -18,6 +18,6 @@
<!-- Main code --> <!-- Main code -->
{{ if and (not $error) (gt $items 1) -}} {{ if and (not $error) (gt $items 1) -}}
<strong class="d-block h6 my-2 pb-2 border-bottom">{{ T "toc" }}</strong> <strong class="d-block h6 my-2 pb-2">{{ T "toc" }}:</strong>
{{ $page.TableOfContents }} {{ $page.TableOfContents }}
{{ end -}} {{ end -}}

View File

@@ -1,8 +1,10 @@
{{ define "head" }} {{ define "head" }}
{{- $version := strings.TrimPrefix "v" (partialCached "assets/version.html" .) -}}
{{ $desc := .Page.Description | default (.Page.Content | safeHTML | truncate 150) -}} {{ $desc := .Page.Description | default (.Page.Content | safeHTML | truncate 150) -}}
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
{{ hugo.Generator }} {{ hugo.Generator }}
<meta name="theme" content="{{ printf "Hinode %s" $version }}">
{{ partialCached "head/stylesheet-core.html" . -}} {{ partialCached "head/stylesheet-core.html" . -}}
{{ $page_modules := slice | append .Page.Params.modules }} {{ $page_modules := slice | append .Page.Params.modules }}
@@ -16,6 +18,9 @@
<link rel="preconnect" href="https://fonts.googleapis.com"> <link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="stylesheet" href="{{ .Site.Params.style.themeFontPath | default "https://fonts.googleapis.com/css2?family=Inter:wght@200;300;600&display=swap" }}"> <link rel="stylesheet" href="{{ .Site.Params.style.themeFontPath | default "https://fonts.googleapis.com/css2?family=Inter:wght@200;300;600&display=swap" }}">
{{ else if .Site.Params.style.themeFontPreload }}
{{ $font := .Site.Params.style.themeFontPreload }}
<link rel="preload" href="{{ $font }}" as="font" type="font/{{ strings.TrimPrefix "." (path.Ext $font) }}" crossorigin>
{{- end -}} {{- end -}}
{{ partial "head/seo.html" . }} {{ partial "head/seo.html" . }}
{{ partialCached "head/favicon.html" . -}} {{ partialCached "head/favicon.html" . -}}

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{ {
"name": "@gethinode/hinode", "name": "@gethinode/hinode",
"version": "0.23.0-beta4", "version": "0.23.0-beta5",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@gethinode/hinode", "name": "@gethinode/hinode",
"version": "0.23.0-beta4", "version": "0.23.0-beta5",
"license": "MIT", "license": "MIT",
"devDependencies": { "devDependencies": {
"@fullhuman/postcss-purgecss": "^5.0.0", "@fullhuman/postcss-purgecss": "^5.0.0",

View File

@@ -1,6 +1,6 @@
{ {
"name": "@gethinode/hinode", "name": "@gethinode/hinode",
"version": "0.23.0-beta4", "version": "0.23.0-beta5",
"description": "Hinode is a clean documentation and blog theme for Hugo, an open-source static site generator", "description": "Hinode is a clean documentation and blog theme for Hugo, an open-source static site generator",
"keywords": [ "keywords": [
"hugo", "hugo",