From bb4f2dce35e61af73cec69c64fefdc63659116e3 Mon Sep 17 00:00:00 2001 From: Aditya Telange <21258296+adityatelange@users.noreply.github.com> Date: Sun, 26 Oct 2025 20:25:02 +0530 Subject: [PATCH] Refactor theme decision logic into head.html for faster script execution. --- layouts/partials/head.html | 45 ++++++++++++++++++++++++++++++++++++ layouts/partials/header.html | 45 ------------------------------------ 2 files changed, 45 insertions(+), 45 deletions(-) diff --git a/layouts/partials/head.html b/layouts/partials/head.html index c99b45e6..565709b4 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -149,6 +149,51 @@ {{- end }} +{{- /* theme-toggle is enabled */}} +{{- if (not site.Params.disableThemeToggle) }} +{{- /* theme is light */}} +{{- if (eq site.Params.defaultTheme "light") }} + +{{- /* theme is dark */}} +{{- else if (eq site.Params.defaultTheme "dark") }} + +{{- else }} +{{- /* theme is auto */}} + +{{- end }} +{{- /* theme-toggle is disabled and theme is auto */}} +{{- else if (and (ne site.Params.defaultTheme "light") (ne site.Params.defaultTheme "dark"))}} + +{{- end }} + {{- partial "extend_head.html" . -}} {{- /* Misc */}} diff --git a/layouts/partials/header.html b/layouts/partials/header.html index 25c58f2b..e3eb7977 100644 --- a/layouts/partials/header.html +++ b/layouts/partials/header.html @@ -1,48 +1,3 @@ -{{- /* theme-toggle is enabled */}} -{{- if (not site.Params.disableThemeToggle) }} -{{- /* theme is light */}} -{{- if (eq site.Params.defaultTheme "light") }} - -{{- /* theme is dark */}} -{{- else if (eq site.Params.defaultTheme "dark") }} - -{{- else }} -{{- /* theme is auto */}} - -{{- end }} -{{- /* theme-toggle is disabled and theme is auto */}} -{{- else if (and (ne site.Params.defaultTheme "light") (ne site.Params.defaultTheme "dark"))}} - -{{- end }} -