diff --git a/assets/js/appearance.js b/assets/js/appearance.js index 2d7385ec..34ee826f 100644 --- a/assets/js/appearance.js +++ b/assets/js/appearance.js @@ -26,16 +26,19 @@ window.addEventListener("DOMContentLoaded", (event) => { const switcher = document.getElementById("appearance-switcher"); const switcherMobile = document.getElementById("appearance-switcher-mobile"); - updateMeta() + updateMeta(); + this.updateLogo?.(getTargetAppearance()); if (switcher) { switcher.addEventListener("click", () => { document.documentElement.classList.toggle("dark"); + var targetAppearance = getTargetAppearance(); localStorage.setItem( "appearance", - document.documentElement.classList.contains("dark") ? "dark" : "light" + targetAppearance ); - updateMeta() + updateMeta(); + this.updateLogo?.(targetAppearance); }); switcher.addEventListener("contextmenu", (event) => { event.preventDefault(); @@ -45,11 +48,13 @@ window.addEventListener("DOMContentLoaded", (event) => { if (switcherMobile) { switcherMobile.addEventListener("click", () => { document.documentElement.classList.toggle("dark"); + var targetAppearance = getTargetAppearance(); localStorage.setItem( "appearance", - document.documentElement.classList.contains("dark") ? "dark" : "light" + targetAppearance ); - updateMeta() + updateMeta(); + this.updateLogo?.(targetAppearance); }); switcherMobile.addEventListener("contextmenu", (event) => { event.preventDefault(); @@ -66,10 +71,31 @@ var updateMeta = () => { document.querySelector('meta[name="theme-color"]').setAttribute('content', style.backgroundColor); } +{{ if and (.Site.Params.Logo) (.Site.Params.SecondaryLogo) }} +{{ $primaryLogo := resources.Get .Site.Params.Logo }} +{{ $secondaryLogo := resources.Get .Site.Params.SecondaryLogo }} +{{ if and ($primaryLogo) ($secondaryLogo) }} +var updateLogo = (targetAppearance) => { + var elems; + elems = document.querySelectorAll("img.logo") + targetLogoPath = + targetAppearance == "{{ .Site.Params.DefaultAppearance }}" ? + "{{ $primaryLogo.RelPermalink }}" : "{{ $secondaryLogo.RelPermalink }}" + for (const elem of elems) { + elem.setAttribute("src", targetLogoPath) + } +} +{{ end }} +{{- end }} + +var getTargetAppearance = () => { + return document.documentElement.classList.contains("dark") ? "dark" : "light" +} + window.addEventListener("DOMContentLoaded", (event) => { const scroller = document.getElementById("top-scroller"); const footer = document.getElementById("site-footer"); if(scroller.getBoundingClientRect().top > footer.getBoundingClientRect().top) { scroller.hidden = true; } -}); \ No newline at end of file +}); diff --git a/config/_default/languages.en.toml b/config/_default/languages.en.toml index 379c57ba..31e570ba 100644 --- a/config/_default/languages.en.toml +++ b/config/_default/languages.en.toml @@ -7,6 +7,7 @@ rtl = false title = "Blowfish" # logo = "img/logo.png" +# secondaryLogo = "img/secondary-logo.png" # description = "My awesome website" # copyright = "Copy, _right?_ :thinking_face:" diff --git a/exampleSite/config/_default/languages.en.toml b/exampleSite/config/_default/languages.en.toml index 5b588adf..6131c4e7 100644 --- a/exampleSite/config/_default/languages.en.toml +++ b/exampleSite/config/_default/languages.en.toml @@ -7,6 +7,7 @@ rtl = false title = "Blowfish" logo = "img/blowfish_logo_transparent.png" +#secondaryLogo = "PATH" description = "A powerful, lightweight theme for Hugo built with Tailwind CSS." # copyright = "Copy, _right?_ :thinking_face:" diff --git a/exampleSite/config/_default/menus.en.toml b/exampleSite/config/_default/menus.en.toml index c8df8eb0..2fe1b1a5 100644 --- a/exampleSite/config/_default/menus.en.toml +++ b/exampleSite/config/_default/menus.en.toml @@ -19,8 +19,6 @@ # name = "Examples" # weight = 20 - - [[main]] name = "Samples" pageRef = "samples" diff --git a/exampleSite/content/docs/configuration/index.md b/exampleSite/content/docs/configuration/index.md index fb4d6da6..af844c6c 100644 --- a/exampleSite/content/docs/configuration/index.md +++ b/exampleSite/content/docs/configuration/index.md @@ -141,6 +141,7 @@ Many of the article defaults here can be overridden on a per article basis by sp | `enableSearch` | `false` | Whether site search is enabled. Set to `true` to enable search functionality. Note that the search feature depends on the `outputs.home` setting in the [site configuration](#site-configuration) being set correctly. | | `enableCodeCopy` | `false` | Whether copy-to-clipboard buttons are enabled for `` blocks. The `highlight.noClasses` parameter must be set to `false` for code copy to function correctly. Read more about [other configuration files](#other-configuration-files) below. | | `logo` | _Not set_ | The relative path to the site logo file within the `assets/` folder. The logo file should be provided at 2x resolution and supports any image dimensions. | +| `secondaryLogo` | _Not set_ | The relative path to the secondary site logo file within the `assets/` folder. The logo file should be provided at 2x resolution and supports any image dimensions. This should have an inverted/contrasting colour scheme to `logo`. If set, this logo will be shown when users toggle from the `defaultAppearance` mode. | | `mainSections` | _Not set_ | The sections that should be displayed in the recent articles list. If not provided the section with the greatest number of articles is used. | | `showViews` | _Not set_ | Whether or not articles and list views are displayed. This requires firebase integrations to be enabled, look below. | | `showLikes` | _Not set_ | Whether or not articles and list likes are displayed. This requires firebase integrations to be enabled, look below. | diff --git a/exampleSite/content/docs/getting-started/index.md b/exampleSite/content/docs/getting-started/index.md index c7835c98..9c6abf68 100644 --- a/exampleSite/content/docs/getting-started/index.md +++ b/exampleSite/content/docs/getting-started/index.md @@ -197,7 +197,7 @@ Both menus are completely optional and can be commented out if not required. Use ### Nested menus -The theme also supports nested menus. In order to use them you just need to define a parent entry in `menu.toml` and its sub-menus using the `parent` parameter to reference the parent. All properties can be used for sub-menus. Note that `pageRef` and `url` will be ignored for the parent entry. Nested menus is only available in the main menu not for the footer. +The theme also supports nested menus. In order to use them you just need to define a parent entry in `menu.toml` and its sub-menus using the `parent` parameter to reference the parent. All properties can be used for sub-menus. `pageRef` and `url` can also be used in the parent entry. Nested menus are only available in the main menu not for the footer. ```toml # config/_default/menus.toml diff --git a/layouts/partials/head.html b/layouts/partials/head.html index 14114599..23de7dda 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -14,7 +14,7 @@ {{- end }} {{/* Metadata */}} - {{ with .Params.Summary | default .Site.Params.description -}} + {{ with (.Params.Summary | default .Params.Description) | default .Site.Params.description -}} {{- end }} {{ with .Params.Tags | default .Site.Params.keywords -}} @@ -50,7 +50,7 @@ {{ $jsAppearance := resources.Get "js/appearance.js" }} - {{ $jsAppearance = $jsAppearance | resources.Minify | resources.Fingerprint "sha512" }} + {{ $jsAppearance = $jsAppearance | resources.ExecuteAsTemplate $jsAppearance.RelPermalink . | resources.Minify | resources.Fingerprint "sha512" }} {{ if .Site.Params.enableSearch | default false }} diff --git a/layouts/partials/header/basic.html b/layouts/partials/header/basic.html index 4a020e1a..c370accc 100644 --- a/layouts/partials/header/basic.html +++ b/layouts/partials/header/basic.html @@ -8,7 +8,7 @@ {{ .Site.Title | markdownify | emojify }} {{ .Site.Title }} + class="logo max-h-[5rem] max-w-[5rem] object-scale-down object-left nozoom" alt="{{ .Site.Title }}" /> diff --git a/layouts/partials/header/header-option-nested.html b/layouts/partials/header/header-option-nested.html index 1cc761b4..068f30e0 100644 --- a/layouts/partials/header/header-option-nested.html +++ b/layouts/partials/header/header-option-nested.html @@ -5,7 +5,8 @@ {{ partial "icon.html" .Pre }} {{ end }} - + {{ .Name | markdownify | emojify }} @@ -31,4 +32,4 @@ - \ No newline at end of file + diff --git a/package-lock.json b/package-lock.json index 4a4800e9..71a1486a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,17 +1,17 @@ { "name": "hugo-blowfish-theme", - "version": "2.33.0", + "version": "2.33.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "hugo-blowfish-theme", - "version": "2.33.0", + "version": "2.33.1", "hasInstallScript": true, "license": "MIT", "dependencies": { "@headlessui/react": "^1.7.14", - "@heroicons/react": "^2.0.17", + "@heroicons/react": "^2.0.18", "@tailwindcss/forms": "^0.5.3", "commander": "^10.0.1" }, @@ -19,7 +19,7 @@ "@tailwindcss/typography": "^0.5.9", "chart.js": "^4.3.0", "fuse.js": "^6.6.2", - "jquery": "^3.6.4", + "jquery": "^3.7.0", "katex": "^0.16.7", "packery": "^2.1.2", "prettier": "^2.8.8", @@ -59,9 +59,9 @@ } }, "node_modules/@heroicons/react": { - "version": "2.0.17", - "resolved": "https://registry.npmjs.org/@heroicons/react/-/react-2.0.17.tgz", - "integrity": "sha512-90GMZktkA53YbNzHp6asVEDevUQCMtxWH+2UK2S8OpnLEu7qckTJPhNxNQG52xIR1WFTwFqtH6bt7a60ZNcLLA==", + "version": "2.0.18", + "resolved": "https://registry.npmjs.org/@heroicons/react/-/react-2.0.18.tgz", + "integrity": "sha512-7TyMjRrZZMBPa+/5Y8lN0iyvUU/01PeMGX2+RE7cQWpEUIcb4QotzUObFkJDejj/HUH4qjP/eQ0gzzKs2f+6Yw==", "peerDependencies": { "react": ">= 16" } @@ -594,9 +594,9 @@ } }, "node_modules/jquery": { - "version": "3.6.4", - "resolved": "https://registry.npmjs.org/jquery/-/jquery-3.6.4.tgz", - "integrity": "sha512-v28EW9DWDFpzcD9O5iyJXg3R3+q+mET5JhnjJzQUZMHOv67bpSIHq81GEYpPNZHG+XXHsfSme3nxp/hndKEcsQ==", + "version": "3.7.0", + "resolved": "https://registry.npmjs.org/jquery/-/jquery-3.7.0.tgz", + "integrity": "sha512-umpJ0/k8X0MvD1ds0P9SfowREz2LenHsQaxSohMZ5OMNEU2r0tf8pdeEFTHMFxWVxKNyU9rTtK3CWzUCTKJUeQ==", "dev": true }, "node_modules/js-tokens": { @@ -1650,9 +1650,9 @@ } }, "@heroicons/react": { - "version": "2.0.17", - "resolved": "https://registry.npmjs.org/@heroicons/react/-/react-2.0.17.tgz", - "integrity": "sha512-90GMZktkA53YbNzHp6asVEDevUQCMtxWH+2UK2S8OpnLEu7qckTJPhNxNQG52xIR1WFTwFqtH6bt7a60ZNcLLA==", + "version": "2.0.18", + "resolved": "https://registry.npmjs.org/@heroicons/react/-/react-2.0.18.tgz", + "integrity": "sha512-7TyMjRrZZMBPa+/5Y8lN0iyvUU/01PeMGX2+RE7cQWpEUIcb4QotzUObFkJDejj/HUH4qjP/eQ0gzzKs2f+6Yw==", "requires": {} }, "@jridgewell/gen-mapping": { @@ -2069,9 +2069,9 @@ "integrity": "sha512-QAdOptna2NYiSSpv0O/BwoHBSmz4YhpzJHyi+fnMRTXFjp7B8i/YG5Z8IfusxB1ufjcD2Sre1F3R+nX3fvy7gg==" }, "jquery": { - "version": "3.6.4", - "resolved": "https://registry.npmjs.org/jquery/-/jquery-3.6.4.tgz", - "integrity": "sha512-v28EW9DWDFpzcD9O5iyJXg3R3+q+mET5JhnjJzQUZMHOv67bpSIHq81GEYpPNZHG+XXHsfSme3nxp/hndKEcsQ==", + "version": "3.7.0", + "resolved": "https://registry.npmjs.org/jquery/-/jquery-3.7.0.tgz", + "integrity": "sha512-umpJ0/k8X0MvD1ds0P9SfowREz2LenHsQaxSohMZ5OMNEU2r0tf8pdeEFTHMFxWVxKNyU9rTtK3CWzUCTKJUeQ==", "dev": true }, "js-tokens": { diff --git a/package.json b/package.json index c06a4bc2..348e147e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hugo-blowfish-theme", - "version": "2.33.1", + "version": "2.33.2", "description": "Blowfish theme for Hugo", "scripts": { "fullinstall": "npm run preinstall && npm install && npm run postinstall", @@ -37,7 +37,7 @@ "@tailwindcss/typography": "^0.5.9", "chart.js": "^4.3.0", "fuse.js": "^6.6.2", - "jquery": "^3.6.4", + "jquery": "^3.7.0", "katex": "^0.16.7", "packery": "^2.1.2", "prettier": "^2.8.8", @@ -94,7 +94,7 @@ ], "dependencies": { "@headlessui/react": "^1.7.14", - "@heroicons/react": "^2.0.17", + "@heroicons/react": "^2.0.18", "@tailwindcss/forms": "^0.5.3", "commander": "^10.0.1" }