Skip to content

Commit c10c10e

Browse files
authored
Merge pull request #88 from bitkarrot/master
add dark mode toggle
2 parents f7c1c4e + 03473b2 commit c10c10e

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

_config.yml

+2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ github_username: chaincodelabs
2929

3030
# Build settings
3131
theme: just-the-docs
32+
# Color scheme supports "light" and "dark"
33+
color_scheme: dark
3234
plugins:
3335
- asciidoctor-diagram
3436
- jekyll-feed

_includes/head_custom.html

+17
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,19 @@
11
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
22
<link rel="stylesheet" href="/css/asciidoc.css">
3+
4+
<button class="btn js-toggle-dark-mode"><i class="fa fa-sun-o"></i></button>
5+
6+
<script>
7+
const toggleDarkMode = document.querySelector('.js-toggle-dark-mode');
8+
const toggleIcon = toggleDarkMode.querySelector('i');
9+
10+
jtd.addEvent(toggleDarkMode, 'click', function() {
11+
if (jtd.getTheme() === 'dark') {
12+
jtd.setTheme('light');
13+
toggleIcon.className = 'fa fa-moon-o';
14+
} else {
15+
jtd.setTheme('dark');
16+
toggleIcon.className = 'fa fa-sun-o';
17+
}
18+
});
19+
</script>

0 commit comments

Comments
 (0)