mirror of
https://github.com/dillonzq/LoveIt.git
synced 2024-11-14 19:06:16 +01:00
Merge pull request #58 from dillonzq/feature/config_default_theme
feat(config): add config for default theme light/dark
This commit is contained in:
commit
dd6c0f7907
5 changed files with 14 additions and 6 deletions
|
@ -14,8 +14,8 @@ jQuery(function($) {
|
||||||
_Blog.toggleTheme = function() {
|
_Blog.toggleTheme = function() {
|
||||||
$('.theme-switch').on('click', () => {
|
$('.theme-switch').on('click', () => {
|
||||||
$('body').toggleClass('dark-theme');
|
$('body').toggleClass('dark-theme');
|
||||||
isDark = !isDark;
|
window.isDark = !window.isDark;
|
||||||
window.localStorage && window.localStorage.setItem('theme', isDark ? 'dark' : 'light');
|
window.localStorage && window.localStorage.setItem('theme', window.isDark ? 'dark' : 'light');
|
||||||
this.echarts();
|
this.echarts();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -110,9 +110,11 @@ dateFormatToUse = "2006-01-02"
|
||||||
description = "About LoveIt Theme"
|
description = "About LoveIt Theme"
|
||||||
# site keywords
|
# site keywords
|
||||||
keywords = ["Theme", "Hugo"]
|
keywords = ["Theme", "Hugo"]
|
||||||
|
# site default theme ("light", "dark")
|
||||||
|
defaultTheme = "light"
|
||||||
|
|
||||||
# Home Page Info
|
# Home Page Info
|
||||||
## [post, other] home mode
|
##home mode ("post", "other")
|
||||||
home_mode = "post"
|
home_mode = "post"
|
||||||
## special amount of posts in each home post page
|
## special amount of posts in each home post page
|
||||||
home_paginate = 6
|
home_paginate = 6
|
||||||
|
|
|
@ -110,9 +110,11 @@ dateFormatToUse = "2006-01-02"
|
||||||
description = "关于 LoveIt 主题"
|
description = "关于 LoveIt 主题"
|
||||||
# 网站关键词
|
# 网站关键词
|
||||||
keywords = ["Theme", "Hugo"]
|
keywords = ["Theme", "Hugo"]
|
||||||
|
# 网站默认主题 ("light", "dark")
|
||||||
|
defaultTheme = "light"
|
||||||
|
|
||||||
# 主页信息设置
|
# 主页信息设置
|
||||||
## [post, other] 主页模式
|
## 主页模式 ("post", "other")
|
||||||
home_mode = "post"
|
home_mode = "post"
|
||||||
## 主页在 post 模式下每页 post 显示数量
|
## 主页在 post 模式下每页 post 显示数量
|
||||||
home_paginate = 6
|
home_paginate = 6
|
||||||
|
|
|
@ -16,7 +16,11 @@
|
||||||
<body>
|
<body>
|
||||||
{{- /* Check theme isDark before body rendering */ -}}
|
{{- /* Check theme isDark before body rendering */ -}}
|
||||||
<script>
|
<script>
|
||||||
|
if (!window.localStorage || !window.localStorage.getItem('theme')) {
|
||||||
|
window.isDark = '{{ .Site.Params.defaultTheme }}' === 'dark';
|
||||||
|
} else {
|
||||||
window.isDark = (window.localStorage && window.localStorage.getItem('theme')) === 'dark';
|
window.isDark = (window.localStorage && window.localStorage.getItem('theme')) === 'dark';
|
||||||
|
}
|
||||||
window.isDark && document.body.classList.add('dark-theme');
|
window.isDark && document.body.classList.add('dark-theme');
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -269,7 +269,7 @@
|
||||||
</a>
|
</a>
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
{{- with .Site.Params.Social.Mastodon}}
|
{{- with .Site.Params.Social.Mastodon}}
|
||||||
{{ $MastodonPrefix := $.Site.Params.Social.MastodonPrefix | default "https://mastodon.social/" }}
|
{{- $MastodonPrefix := $.Site.Params.Social.MastodonPrefix | default "https://mastodon.social/" -}}
|
||||||
<a href="{{ $MastodonPrefix | safeURL }}{{ . }}" rel="me noopener noreffer" target="_blank">
|
<a href="{{ $MastodonPrefix | safeURL }}{{ . }}" rel="me noopener noreffer" target="_blank">
|
||||||
<i class="fab fa-mastodon fa-fw" title="Mastodon"></i>
|
<i class="fab fa-mastodon fa-fw" title="Mastodon"></i>
|
||||||
</a>
|
</a>
|
||||||
|
|
Loading…
Reference in a new issue