mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2026-04-10 21:17:07 +08:00
新增head标签内theme-color的配置项
This commit is contained in:
@@ -470,6 +470,8 @@ site_verification:
|
|||||||
# blockquote_padding_color: "#49b1f5"
|
# blockquote_padding_color: "#49b1f5"
|
||||||
# blockquote_background_color: "#49b1f5"
|
# blockquote_background_color: "#49b1f5"
|
||||||
# scrollbar_color: "#49b1f5"
|
# scrollbar_color: "#49b1f5"
|
||||||
|
# meta_theme_color_light: "ffffff"
|
||||||
|
# meta_theme_color_dark: "#0d0d0d"
|
||||||
|
|
||||||
# The top_img settings of home page
|
# The top_img settings of home page
|
||||||
# default: top img - full screen, site info - middle (默認top_img全屏,site_info在中間)
|
# default: top img - full screen, site info - middle (默認top_img全屏,site_info在中間)
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
- else pageKeywords = Array.isArray(config.keywords) ? (config.keywords).join(','): ([]).join(',') || config.keywords
|
- else pageKeywords = Array.isArray(config.keywords) ? (config.keywords).join(','): ([]).join(',') || config.keywords
|
||||||
- var pageAuthor = config.email ? config.author + ',' + config.email : config.author
|
- var pageAuthor = config.email ? config.author + ',' + config.email : config.author
|
||||||
- var pageCopyright = config.copyright || config.author
|
- var pageCopyright = config.copyright || config.author
|
||||||
- var themeColor = theme.display_mode === 'dark' ? '#0d0d0d' : '#ffffff'
|
- var themeColor = theme.display_mode === 'dark' ? theme.theme_color.meta_theme_color_dark : theme.theme_color.meta_theme_color_light
|
||||||
|
|
||||||
meta(charset='UTF-8')
|
meta(charset='UTF-8')
|
||||||
meta(http-equiv="X-UA-Compatible" content="IE=edge")
|
meta(http-equiv="X-UA-Compatible" content="IE=edge")
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
hexo.extend.helper.register('inject_head_js', function () {
|
hexo.extend.helper.register('inject_head_js', function () {
|
||||||
const { darkmode, aside } = this.theme
|
const { darkmode, aside } = this.theme
|
||||||
|
|
||||||
|
const { theme_color } = hexo.theme.config
|
||||||
|
|
||||||
const localStore = `
|
const localStore = `
|
||||||
win.saveToLocal = {
|
win.saveToLocal = {
|
||||||
set: function setWithExpiry(key, value, ttl) {
|
set: function setWithExpiry(key, value, ttl) {
|
||||||
@@ -62,13 +64,13 @@ hexo.extend.helper.register('inject_head_js', function () {
|
|||||||
win.activateDarkMode = function () {
|
win.activateDarkMode = function () {
|
||||||
document.documentElement.setAttribute('data-theme', 'dark')
|
document.documentElement.setAttribute('data-theme', 'dark')
|
||||||
if (document.querySelector('meta[name="theme-color"]') !== null) {
|
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 () {
|
win.activateLightMode = function () {
|
||||||
document.documentElement.setAttribute('data-theme', 'light')
|
document.documentElement.setAttribute('data-theme', 'light')
|
||||||
if (document.querySelector('meta[name="theme-color"]') !== null) {
|
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')
|
const t = saveToLocal.get('theme')
|
||||||
|
|||||||
Reference in New Issue
Block a user