mirror of
https://github.com/thegeeklab/hugo-geekblog.git
synced 2024-11-21 12:40:39 +00:00
feat: add option to enable or disable the dark mode toggle button (#346)
This commit is contained in:
parent
890df329dc
commit
b11460f532
@ -114,6 +114,10 @@ enableRobotsTXT = true
|
||||
# See https://developer.mozilla.org/de/docs/Web/HTML/Element/base.
|
||||
geekblogOverwriteHTMLBase = false
|
||||
|
||||
# (Optional, default true) Enable or disable the JavaScript based color theme toggle switch. The CSS based
|
||||
# user preference mode still works.
|
||||
geekblogDarkModeToggle = false
|
||||
|
||||
# (Optional, default true) Enable or disable adding tags automatically to the main menu.
|
||||
geekblogTagsToMenu = true
|
||||
|
||||
@ -250,6 +254,10 @@ params:
|
||||
# See https://developer.mozilla.org/de/docs/Web/HTML/Element/base.
|
||||
geekblogOverwriteHTMLBase: false
|
||||
|
||||
# (Optional, default true) Enable or disable the JavaScript based color theme toggle switch. The CSS based
|
||||
# user preference mode still works.
|
||||
geekblogDarkModeToggle: false
|
||||
|
||||
# (Optional, default true) Enable or disable adding tags automatically to the main menu.
|
||||
geekblogTagsToMenu: true
|
||||
|
||||
|
@ -1,3 +1,6 @@
|
||||
{{- if default true .Site.Params.GeekblogDarkModeToggle }}
|
||||
<script src="{{ index (index .Site.Data.assets "colortheme.js") "src" | relURL }}"></script>
|
||||
{{- end }}
|
||||
<script src="{{ index (index .Site.Data.assets "main.js") "src" | relURL }}"></script>
|
||||
|
||||
<link
|
||||
|
@ -1,11 +1,6 @@
|
||||
const { applyTheme } = require("./colorTheme")
|
||||
const { createCopyButton } = require("./copycode.js")
|
||||
const Clipboard = require("clipboard")
|
||||
|
||||
;(() => {
|
||||
applyTheme()
|
||||
})()
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function (event) {
|
||||
let clipboard = new Clipboard(".clip")
|
||||
|
||||
|
@ -1,7 +1,10 @@
|
||||
const Storage = require("store2")
|
||||
|
||||
const { TOGGLE_COLOR_THEMES, THEME, COLOR_THEME_AUTO } = require("./config.js")
|
||||
|
||||
;(() => {
|
||||
applyTheme()
|
||||
})()
|
||||
|
||||
document.addEventListener("DOMContentLoaded", (event) => {
|
||||
const colorThemeToggle = document.getElementById("gblog-color-theme")
|
||||
|
||||
@ -15,7 +18,7 @@ document.addEventListener("DOMContentLoaded", (event) => {
|
||||
}
|
||||
})
|
||||
|
||||
export function applyTheme(init = true) {
|
||||
function applyTheme(init = true) {
|
||||
if (Storage.isFake()) return
|
||||
|
||||
let lstore = Storage.namespace(THEME)
|
||||
|
@ -36,11 +36,7 @@ html {
|
||||
|
||||
&.color-toggle-hidden {
|
||||
#gblog-color-theme {
|
||||
.gblog_brightness_auto,
|
||||
.gblog_brightness_dark,
|
||||
.gblog_brightness_light {
|
||||
display: none;
|
||||
}
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,7 @@ var config = {
|
||||
path.resolve("src", "sass", "print.scss")
|
||||
],
|
||||
main: path.resolve("src", "js", "app.js"),
|
||||
colortheme: path.resolve("src", "js", "colorTheme.js"),
|
||||
mermaid: path.resolve("src", "js", "mermaid.js"),
|
||||
katex: [path.resolve("src", "js", "katex.js")].concat(
|
||||
glob.sync(path.join(nodeModulesPath, "katex", "dist", "fonts", "*.{woff,woff2}"))
|
||||
|
Loading…
Reference in New Issue
Block a user