Simplify theme-mode config

This commit is contained in:
Cotes Chung 2020-12-07 01:14:40 +08:00
parent 8d4c555638
commit bb13b52d44
3 changed files with 10 additions and 9 deletions

View File

@ -67,16 +67,17 @@ disqus:
shortname: '' # Fill with your Disqus shortname. https://help.disqus.com/en/articles/1717111-what-s-a-shortname shortname: '' # Fill with your Disqus shortname. https://help.disqus.com/en/articles/1717111-what-s-a-shortname
# Prefer color scheme setting, available values: # Prefer color scheme setting, keep empty will follow the system prefer color by default.
# And there will be a toggle to switch the theme between dark and light
# on the bottom left of the sidebar.
# #
# dual - Follow the system prefer color by default, and a toggle will display # Available values:
# in the left bottom of Sidebar, which used for switch the theme between dark and light.
# #
# light - Use the light color scheme # light - Use the light color scheme
# #
# dark - Use the dark color scheme # dark - Use the dark color scheme
# #
theme_mode: dual theme_mode:
# boolean type, the global switch for ToC in posts. # boolean type, the global switch for ToC in posts.
toc: true toc: true

View File

@ -52,12 +52,12 @@
<div class="sidebar-bottom d-flex flex-wrap justify-content-around mt-4"> <div class="sidebar-bottom d-flex flex-wrap justify-content-around mt-4">
{% if site.theme_mode == "dual" %} {% unless site.theme_mode %}
<span id="mode-toggle-wrapper"> <span id="mode-toggle-wrapper">
{% include mode-toggle.html %} {% include mode-toggle.html %}
</span> </span>
<span class="icon-border"></span> <span class="icon-border"></span>
{% endif %} {% endunless %}
{% for entry in site.data.contact %} {% for entry in site.data.contact %}
{% capture url %} {% capture url %}

View File

@ -10,12 +10,12 @@ layout: compress
<!DOCTYPE html> <!DOCTYPE html>
{% capture prefer_mode %} {% capture prefer_mode %}
{% unless site.theme_mode == "dual" %} {% if site.theme_mode %}
mode="{{ site.theme_mode }}" mode="{{ site.theme_mode }}"
{% endunless %} {% endif %}
{% endcapture %} {% endcapture %}
<html lang="{{ site.lang | split: "_" | first | default: "en" }}" {{ prefer_mode }} > <html lang="{{ site.lang | split: "_" | first | default: "en" }}" {{ prefer_mode }}>
{% include head.html %} {% include head.html %}