From fe1609440ec931a7334dd099bf0e0ca5654dafd7 Mon Sep 17 00:00:00 2001 From: Eltrac Date: Thu, 11 Sep 2025 11:46:46 +0800 Subject: refactor: header into modular partials Former-commit-id: 7f66ff9a5c84e54b119fb880da5aaa95b9c44552 --- layouts/_partials/header.html | 51 +++------------------------ layouts/_partials/header/hoverable-logo.html | 15 ++++++++ layouts/_partials/header/language-switch.html | 17 +++++++++ layouts/_partials/header/navigation.html | 15 ++++++++ 4 files changed, 51 insertions(+), 47 deletions(-) create mode 100644 layouts/_partials/header/hoverable-logo.html create mode 100644 layouts/_partials/header/language-switch.html create mode 100644 layouts/_partials/header/navigation.html diff --git a/layouts/_partials/header.html b/layouts/_partials/header.html index 35d997e8..d2205e9b 100644 --- a/layouts/_partials/header.html +++ b/layouts/_partials/header.html @@ -1,23 +1,7 @@
- +
- -
-
- {{ partial "components/logo" (dict "imageClass" "w-[10rem]") }} -
-
-

- {{ T "homePageQuote.content" . | markdownify }} -

-

- {{ T "homePageQuote.source" . | markdownify }} -

-
-
- + {{ partial "header/hoverable-logo" . }} {{ $navOffset := "pl-6" }} - {{ $langButtonSize := "w-4 h-4" }}
- - - {{- $lang := .Site.Language.Lang -}} - {{- $switch := dict - "en" (dict "url" "/zh/" "label" "ZH" "title" "查看中文博客") - "zh" (dict "url" "/en/" "label" "EN" "title" "View English Blog") -}} - {{- $entry := index $switch $lang -}} - - {{ $entry.label }} - + {{ partial "header/navigation" . }} + {{ partial "header/language-switch" . }}
diff --git a/layouts/_partials/header/hoverable-logo.html b/layouts/_partials/header/hoverable-logo.html new file mode 100644 index 00000000..d04ae6ac --- /dev/null +++ b/layouts/_partials/header/hoverable-logo.html @@ -0,0 +1,15 @@ +
+
+ {{ partial "components/logo" (dict "imageClass" "w-[10rem]") }} +
+
+

+ {{ T "homePageQuote.content" . | markdownify }} +

+

+ {{ T "homePageQuote.source" . | markdownify }} +

+
+
diff --git a/layouts/_partials/header/language-switch.html b/layouts/_partials/header/language-switch.html new file mode 100644 index 00000000..49f4c92a --- /dev/null +++ b/layouts/_partials/header/language-switch.html @@ -0,0 +1,17 @@ +{{ $langButtonSize := "w-4 h-4" }} + +{{- $lang := .Site.Language.Lang -}} +{{- $switch := dict + "en" (dict "url" "/zh/" "label" "ZH" "title" "查看中文博客") + "zh" (dict "url" "/en/" "label" "EN" "title" "View English Blog") -}} +{{- $entry := index $switch $lang -}} + + {{ $entry.label }} + diff --git a/layouts/_partials/header/navigation.html b/layouts/_partials/header/navigation.html new file mode 100644 index 00000000..b3e03aeb --- /dev/null +++ b/layouts/_partials/header/navigation.html @@ -0,0 +1,15 @@ + -- cgit v1.2.3