hugo-toha/layouts/partials/navigators/theme-selector.html
JY Hsu 7bc37c74c7
Added default theme (#960)
* feat: Added default theme

* Revert "feat: Added default theme"

This reverts commit a11a99f92a.

* feat: Add basic theme feature

* feat: Add theme settings

* fix: Fix default theme value

* fix: Fix CR and doc-string

* Comment out darkMode on exampleSite/hugo.yaml

Signed-off-by: hossainemruz <hossainemruz@gmail.com>

---------

Signed-off-by: hossainemruz <hossainemruz@gmail.com>
Co-authored-by: Emruz Hossain <hossainemruz@gmail.com>
2024-09-06 16:15:33 +06:00

31 lines
1.4 KiB
HTML

{{/* variables for enabling/disabling various features */}}
{{ $darkEnabled := true }}
{{ $lightEnabled := true }}
{{ if site.Params.features.theme.enable }}
{{ $darkEnabled = site.Params.features.theme.services.dark | default true }}
{{ $lightEnabled = site.Params.features.theme.services.light | default true }}
{{ end }}
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="themeSelector" role="button"
data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<img id="navbar-theme-icon-svg" class="theme-icon" src="{{ "icons/moon-svgrepo-com.svg" | relURL }}" width=20 alt="Dark Theme">
</a>
<div id="themeMenu" class="dropdown-menu dropdown-menu-icons-only" aria-labelledby="themeSelector">
{{ if $lightEnabled }}
<a class="dropdown-item nav-link" href="#" data-scheme="light">
<img class="theme-icon" src="{{ "icons/sun-svgrepo-com.svg" | relURL }}" width=20 alt="Light Theme">
</a>
{{ end }}
{{ if $darkEnabled }}
<a class="dropdown-item nav-link" href="#" data-scheme="dark">
<img class="theme-icon" src="{{ "icons/moon-svgrepo-com.svg" | relURL }}" width=20 alt="Dark Theme">
</a>
{{ end }}
{{ if and $lightEnabled $darkEnabled }}
<a class="dropdown-item nav-link" href="#" data-scheme="system">
<img class="theme-icon" src="{{ "icons/computer-svgrepo-com.svg" | relURL }}" width=20 alt="System Theme">
</a>
{{ end }}
</div>
</li>