Fix defaultTheme selection as we are using data-theme attribute

Refactor code for selecting class for body as list
This commit is contained in:
Aditya Telange
2025-10-26 21:12:51 +05:30
parent bb4f2dce35
commit 1cf53273c3

View File

@@ -3,21 +3,25 @@
{{- end -}}
<!DOCTYPE html>
<html lang="{{ site.Language }}" dir="{{ .Language.LanguageDirection | default "auto" }}">
{{- $theme := site.Params.defaultTheme | default "auto" }}
{{- if eq $theme "dark" }}
<html lang="{{ site.Language }}" dir="{{ .Language.LanguageDirection | default "auto" }}" data-theme="dark">
{{- else if eq $theme "light" }}
<html lang="{{ site.Language }}" dir="{{ .Language.LanguageDirection | default "auto" }}" data-theme="light">
{{- else }}
<html lang="{{ site.Language }}" dir="{{ .Language.LanguageDirection | default "auto" }}" data-theme="auto">
{{- end }}
<head>
{{- partial "head.html" . }}
</head>
<body class="
{{- if (or (ne .Kind `page` ) (eq .Layout `archives`) (eq .Layout `search`)) -}}
{{- print "list" -}}
{{- end -}}
{{- if eq site.Params.defaultTheme `dark` -}}
{{- print " dark" }}
{{- end -}}
" id="top">
{{- partialCached "header.html" . .Page -}}
{{- if (or (ne .Kind `page` ) (eq .Layout `archives`) (eq .Layout `search`)) }}
<body class="list" id="top">
{{- else }}
<body id="top">
{{- end }}
{{ partialCached "header.html" . .Page -}}
<main class="main">
{{- block "main" . }}{{ end }}
</main>