From c78c7f5bd1d1f5f5d8d37daade0ff27a7a59b479 Mon Sep 17 00:00:00 2001 From: welpo Date: Tue, 8 Aug 2023 00:47:24 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20allow=20setting=20the=20def?= =?UTF-8?q?ault=20theme?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Used as fallback when JS is disabled and `theme_switcher` is enabled. If `default_theme` is unset, it defaults to "light". Used as single theme when `theme_switcher` is disabled. --- config.toml | 11 +++++++++-- templates/base.html | 5 ++++- theme.toml | 11 +++++++++-- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/config.toml b/config.toml index 2d0780b74..a6274e31b 100644 --- a/config.toml +++ b/config.toml @@ -133,10 +133,17 @@ language_name.ca = "Català" language_name.en = "English" language_name.es = "Español" -# Enable JavaScript theme toggler for dark/light mode (and automatic switching). -# The default setting is the light theme. +# Enable JavaScript theme toggler to allow users to switch between dark/light mode. +# Also enables automatic switching based on user's OS-level theme settings. +# If disabled, your site will only use the theme specified in the `default_theme` variable. theme_switcher = true +# This setting determines the default theme ("light" or "dark"). +# If you wish to use only a dark or light theme, disable the `theme_switcher` above and set this variable. +# If `theme_switcher` is enabled, this will be the theme that is visible to users who have JavaScript disabled. +# Defaults to "light", if unset. +default_theme = "light" + # Add a "copy" button to codeblocks (loads ~700 bytes of JavaScript). copy_button = true diff --git a/templates/base.html b/templates/base.html index c2ecd327c..12b773c8f 100644 --- a/templates/base.html +++ b/templates/base.html @@ -9,7 +9,10 @@ {% import "macros/add_comments.html" as macros_add_comments %} - + + {% include "partials/header.html" %} diff --git a/theme.toml b/theme.toml index a24e4af57..cd9eea503 100644 --- a/theme.toml +++ b/theme.toml @@ -26,10 +26,17 @@ language_name.ca = "Català" language_name.en = "English" language_name.es = "Español" -# Enable JavaScript theme toggler for dark/light mode (and automatic switching). -# The default setting is the light theme. +# Enable JavaScript theme toggler to allow users to switch between dark/light mode. +# Also enables automatic switching based on user's OS-level theme settings. +# If disabled, your site will only use the theme specified in the `default_theme` variable. theme_switcher = true +# This setting determines the default theme ("light" or "dark"). +# If you wish to use only a dark or light theme, disable the `theme_switcher` above and set this variable. +# If `theme_switcher` is enabled, this will be the theme that is visible to users who have JavaScript disabled. +# Defaults to "light", if unset. +default_theme = "light" + # Add a "copy" button to codeblocks (loads ~700 bytes of JavaScript). copy_button = true