新增head标签内theme-color的配置项

This commit is contained in:
ImCaO
2022-02-25 19:55:45 +08:00
Unverified
parent 4248103024
commit 7ebed025f0
3 changed files with 7 additions and 3 deletions

View File

@@ -8,6 +8,8 @@
hexo.extend.helper.register('inject_head_js', function () {
const { darkmode, aside } = this.theme
const { theme_color } = hexo.theme.config
const localStore = `
win.saveToLocal = {
set: function setWithExpiry(key, value, ttl) {
@@ -62,13 +64,13 @@ hexo.extend.helper.register('inject_head_js', function () {
win.activateDarkMode = function () {
document.documentElement.setAttribute('data-theme', 'dark')
if (document.querySelector('meta[name="theme-color"]') !== null) {
document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
document.querySelector('meta[name="theme-color"]').setAttribute('content', '${theme_color.meta_theme_color_dark}')
}
}
win.activateLightMode = function () {
document.documentElement.setAttribute('data-theme', 'light')
if (document.querySelector('meta[name="theme-color"]') !== null) {
document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
document.querySelector('meta[name="theme-color"]').setAttribute('content', '${theme_color.meta_theme_color_light}')
}
}
const t = saveToLocal.get('theme')