Skip to content

Commit f7b1605

Browse files
committed
Feature: Make theme colors configurable.
1 parent 387937c commit f7b1605

3 files changed

Lines changed: 22 additions & 1 deletion

File tree

_config.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,18 @@ disqus:
6767
# The year your website first ran.
6868
first_run: 2019
6969

70+
71+
# Prefer color scheme setting, available values:
72+
#
73+
# dual - Follow the system prefer color by default, and a toggle will display
74+
# in the left bottom of Sidebar, which used for switch the theme between dark and light.
75+
#
76+
# light - Use the light color scheme
77+
#
78+
# dark - Use the dark color scheme
79+
#
80+
theme_mode: dual
81+
7082
# boolean type, global switch for ToC in posts.
7183
toc: true
7284

_includes/sidebar.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,11 @@
5757

5858
<div class="sidebar-bottom d-flex justify-content-around mt-4">
5959

60+
{% if site.theme_mode == "dual" %}
6061
<span id="mode-toggle-wrapper" class="d-flex justify-content-center align-items-center">
6162
{% include mode-toggle.html %}
6263
</span>
64+
{% endif %}
6365

6466
<a href="https://github.com/{{ site.github.username }}" target="_blank">
6567
<i class="fab fa-github-alt"></i>

_layouts/default.html

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,14 @@
88
---
99

1010
<!DOCTYPE html>
11-
<html lang="en">
11+
12+
{% capture prefer_mode %}
13+
{% if site.theme_mode != "dual" %}
14+
mode="{{ site.theme_mode }}"
15+
{% endif %}
16+
{% endcapture %}
17+
18+
<html lang="en" {{ prefer_mode }} >
1219

1320
{% include head.html %}
1421

0 commit comments

Comments
 (0)