diff --git a/assets/css/_common/_page/home.scss b/assets/css/_common/_page/home.scss
index 55f6c30..0556754 100644
--- a/assets/css/_common/_page/home.scss
+++ b/assets/css/_common/_page/home.scss
@@ -31,6 +31,9 @@
}
}
}
+ .avatar.dark {
+ display: none;
+ }
}
h2.description {
diff --git a/assets/js/main.js b/assets/js/main.js
index fddf3fa..bde27f3 100644
--- a/assets/js/main.js
+++ b/assets/js/main.js
@@ -32,9 +32,22 @@ jQuery(function($) {
_Blog.toggleTheme = function() {
const currentTheme = window.localStorage && window.localStorage.getItem('theme')
const isDark = currentTheme === 'dark'
+ var toggleVisibility = function(getDark) {
+ if (getDark) {
+ $('.dark').show()
+ $('.light').hide()
+ } else {
+ $('.dark').hide()
+ $('.light').show()
+ }
+ }
+ toggleVisibility(isDark)
$('body').toggleClass('dark-theme', isDark)
$('.theme-switch').on('click', () => {
$('body').toggleClass('dark-theme')
+ const currentTheme = window.localStorage && window.localStorage.getItem('theme')
+ const isDark = currentTheme === 'dark'
+ toggleVisibility(!isDark)
window.localStorage &&
window.localStorage.setItem('theme', document.body.classList.contains('dark-theme') ? 'dark' : 'light', )
})
diff --git a/exampleSite/config.toml b/exampleSite/config.toml
index e91dff2..21219f0 100644
--- a/exampleSite/config.toml
+++ b/exampleSite/config.toml
@@ -43,6 +43,7 @@ preserveTaxonomyNames = true
since = 2011
author = "Covey.Liu" # Author's name
avatar = "/images/me/avatar.jpeg" # Author's avatar
+ avatar_dark = "/images/me/avatar_dark.jpeg" # Optional dark theme avatar
subtitle = "我会更好,因为我没有停止" # Subtitle
cdn_url = "" # Base CDN URL
home_mode = "" # post or other
diff --git a/layouts/partials/head.html b/layouts/partials/head.html
index 2e08a5f..51204c4 100644
--- a/layouts/partials/head.html
+++ b/layouts/partials/head.html
@@ -15,6 +15,11 @@
+
+
+
+
+
diff --git a/layouts/partials/home_post.html b/layouts/partials/home_post.html
index e3e9364..120ab29 100644
--- a/layouts/partials/home_post.html
+++ b/layouts/partials/home_post.html
@@ -4,9 +4,17 @@
{{ $cdn_url := .Scratch.Get "cdn_url" }}
{{ with .Site.Params.avatar}}
{{ $avatar := .}}
-
+
+
+ {{ end }}
+ {{ with .Site.Params.avatar_dark}}
+ {{ $avatar := .}}
+
+
+
+
{{ end }}
{{ with .Site.Params.subtitle}}
diff --git a/layouts/partials/home_profile.html b/layouts/partials/home_profile.html
index cb81002..e2ab043 100644
--- a/layouts/partials/home_profile.html
+++ b/layouts/partials/home_profile.html
@@ -2,7 +2,13 @@
{{ $cdn_url := .Scratch.Get "cdn_url" }}
{{ with .Site.Params.avatar}}
{{ $avatar := .}}
-
+
+
+
+ {{ end }}
+ {{ with .Site.Params.avatar_dark}}
+ {{ $avatar := .}}
+
{{ end }}
diff --git a/layouts/partials/js.html b/layouts/partials/js.html
index f78dc70..1faf0e8 100644
--- a/layouts/partials/js.html
+++ b/layouts/partials/js.html
@@ -9,17 +9,31 @@
{{ $lihtGallery_init := resources.Get "/js/lightGallery-init.js" }}
{{ if .IsPage }}
+ {{ $vendorscript := "" }}
{{ if $postHasImages }}
- {{ $vendorscript := slice $jquery $lazysizes $prettify $dynamic $main $lihtGallery $lihtGallery_init | resources.Concat "/js/vendor_gallery.js" | resources.Minify }}
+ {{ if eq ( getenv "HUGO_ENV" ) "production" }}
+ {{ $vendorscript = slice $jquery $lazysizes $prettify $dynamic $main $lihtGallery $lihtGallery_init | resources.Concat "/js/vendor_gallery.js" | resources.Minify }}
+ {{ else }}
+ {{ $vendorscript = slice $jquery $lazysizes $prettify $dynamic $main $lihtGallery $lihtGallery_init | resources.Concat "/js/vendor_gallery.js" }}
+ {{ end }}
{{ else }}
- {{ $vendorscript := slice $jquery $prettify $dynamic $main | resources.Concat "/js/vendor_no_gallery.js" | resources.Minify }}
+ {{ if eq ( getenv "HUGO_ENV" ) "production" }}
+ {{ $vendorscript = slice $jquery $prettify $dynamic $main | resources.Concat "/js/vendor_no_gallery.js" | resources.Minify }}
+ {{ else }}
+ {{ $vendorscript = slice $jquery $prettify $dynamic $main | resources.Concat "/js/vendor_no_gallery.js" }}
+ {{ end }}
{{ end }}
{{ else }}
- {{ $main := slice $jquery $main | resources.Concat "/js/vendor_main.js" | resources.Minify}}
+
+ {{ if eq ( getenv "HUGO_ENV" ) "production" }}
+ {{ $main = slice $jquery $main | resources.Concat "/js/vendor_main.js" | resources.Minify }}
+ {{ else }}
+ {{ $main = slice $jquery $main | resources.Concat "/js/vendor_main.js" }}
+ {{ end }}
{{ end }}