From 095089fb3f05fd37e401ce407daef87224a96e0d Mon Sep 17 00:00:00 2001 From: Dillon Date: Sat, 8 Feb 2020 22:19:22 +0800 Subject: [PATCH] feat(config): add config for default theme light/dark --- assets/js/blog.js | 4 ++-- exampleSite/config.toml | 4 +++- exampleSite/zh/config.toml | 4 +++- layouts/_default/baseof.html | 6 +++++- layouts/partials/home/social.html | 2 +- 5 files changed, 14 insertions(+), 6 deletions(-) diff --git a/assets/js/blog.js b/assets/js/blog.js index d68201ca..81b81d0d 100644 --- a/assets/js/blog.js +++ b/assets/js/blog.js @@ -14,8 +14,8 @@ jQuery(function($) { _Blog.toggleTheme = function() { $('.theme-switch').on('click', () => { $('body').toggleClass('dark-theme'); - isDark = !isDark; - window.localStorage && window.localStorage.setItem('theme', isDark ? 'dark' : 'light'); + window.isDark = !window.isDark; + window.localStorage && window.localStorage.setItem('theme', window.isDark ? 'dark' : 'light'); this.echarts(); }); }; diff --git a/exampleSite/config.toml b/exampleSite/config.toml index b8aba278..c11d1456 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -110,9 +110,11 @@ dateFormatToUse = "2006-01-02" description = "About LoveIt Theme" # site keywords keywords = ["Theme", "Hugo"] + # site default theme ("light", "dark") + defaultTheme = "light" # Home Page Info - ## [post, other] home mode + ##home mode ("post", "other") home_mode = "post" ## special amount of posts in each home post page home_paginate = 6 diff --git a/exampleSite/zh/config.toml b/exampleSite/zh/config.toml index cd822bd6..d84263b0 100644 --- a/exampleSite/zh/config.toml +++ b/exampleSite/zh/config.toml @@ -110,9 +110,11 @@ dateFormatToUse = "2006-01-02" description = "关于 LoveIt 主题" # 网站关键词 keywords = ["Theme", "Hugo"] + # 网站默认主题 ("light", "dark") + defaultTheme = "light" # 主页信息设置 - ## [post, other] 主页模式 + ## 主页模式 ("post", "other") home_mode = "post" ## 主页在 post 模式下每页 post 显示数量 home_paginate = 6 diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index c4bfea5f..d8b40c69 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -16,7 +16,11 @@ {{- /* Check theme isDark before body rendering */ -}} diff --git a/layouts/partials/home/social.html b/layouts/partials/home/social.html index c22655eb..5fa3511f 100644 --- a/layouts/partials/home/social.html +++ b/layouts/partials/home/social.html @@ -269,7 +269,7 @@ {{- end -}} {{- with .Site.Params.Social.Mastodon}} - {{ $MastodonPrefix := $.Site.Params.Social.MastodonPrefix | default "https://mastodon.social/" }} + {{- $MastodonPrefix := $.Site.Params.Social.MastodonPrefix | default "https://mastodon.social/" -}}