* Initial commit for dark theme. * Use DarkReader.auto() to watch for system theme. * Tunning default parameters. * Allow configurable number of recent posts. * Added invisible element to hack theme initialization. * Added default value. * Use Darkreader CDN. * Cleanup to keep darkreader in as few files as possible. * Renamed darkmode.js to darkmode-darkreader.js. * Bring back the initialization. * Added provider property. * Added theme selector to the posts navbar. * Removed extra line breaks. * Changed darkreader CDN to local copy. * Renamed to darkMode. * Fixed CodeQL failures. * Added icons. * Renamed function. * Added SVG inversion. * Used icons for selection. * Toggle initial dark only in the dynamic navbar. Co-authored-by: donfiguerres <donfiguerres@github.com> Co-authored-by: Emruz Hossain <hossainemruz@gmail.com>
63 lines
2.1 KiB
HTML
63 lines
2.1 KiB
HTML
{{/* by default, don't use any logo */}}
|
|
{{ $mainLogo := "" }}
|
|
{{ $invertedLogo := "" }}
|
|
|
|
{{/* if custom logo has been provided, use them */}}
|
|
{{ if site.Params.logo.main }}
|
|
{{ $mainLogo = site.Params.logo.main }}
|
|
{{ end }}
|
|
{{ if site.Params.logo.inverted }}
|
|
{{ $invertedLogo = site.Params.logo.inverted }}
|
|
{{ end }}
|
|
|
|
{{/* resize the logos. don't resize svg because it is not supported */}}
|
|
{{ if $mainLogo }}
|
|
{{ $mainLogo = resources.Get $mainLogo}}
|
|
{{ if and $mainLogo (ne $mainLogo.MediaType.SubType "svg") }}
|
|
{{ $mainLogo = $mainLogo.Resize "42x" }}
|
|
{{ end }}
|
|
{{ $mainLogo = $mainLogo.RelPermalink}}
|
|
{{ end }}
|
|
|
|
{{ if $invertedLogo }}
|
|
{{ $invertedLogo = resources.Get $invertedLogo}}
|
|
{{ if and $invertedLogo (ne $invertedLogo.MediaType.SubType "svg")}}
|
|
{{ $invertedLogo = $invertedLogo.Resize "42x" }}
|
|
{{ end }}
|
|
{{ $invertedLogo = $invertedLogo.RelPermalink}}
|
|
{{ end }}
|
|
|
|
<nav class="navbar navbar-expand-xl top-navbar final-navbar shadow">
|
|
<div class="container">
|
|
<button class="navbar-toggler navbar-light" id="sidebar-toggler" type="button" onclick="toggleSidebar()">
|
|
<span class="navbar-toggler-icon"></span>
|
|
</button>
|
|
<a class="navbar-brand" href="{{ site.BaseURL | relLangURL }}">
|
|
{{ if $mainLogo }}
|
|
<img src="{{ $mainLogo }}" alt="Logo">
|
|
{{ end }}
|
|
{{- site.Title -}}
|
|
</a>
|
|
<button class="navbar-toggler navbar-light" id="toc-toggler" type="button" onclick="toggleTOC()">
|
|
<span class="navbar-toggler-icon"></span>
|
|
</button>
|
|
|
|
<div class="collapse navbar-collapse lang-selector" id="top-nav-items">
|
|
<ul class="navbar-nav ml-auto">
|
|
{{ if .IsTranslated }}
|
|
{{ partial "navigators/lang-selector-2.html" . }}
|
|
{{ end }}
|
|
{{ if site.Params.darkMode.enable }}
|
|
{{ partial "navigators/theme-selector.html" . }}
|
|
{{ end }}
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
<!-- Store the logo information in a hidden img for the JS -->
|
|
{{ if $mainLogo }}
|
|
<img src="{{ $mainLogo }}" class="d-none" id="main-logo" alt="Logo">
|
|
{{ end }}
|
|
{{ if $invertedLogo }}
|
|
<img src="{{ $invertedLogo }}" class="d-none" id="inverted-logo" alt="Inverted Logo">
|
|
{{ end }}
|
|
</nav>
|