From 0b350db741481a9a7924457259d2d8049f23d437 Mon Sep 17 00:00:00 2001 From: Sped0n Date: Mon, 30 Oct 2023 15:56:43 +0800 Subject: [PATCH] feat(layouts): add baseof.html layout template This commit adds a new layout template called baseof.html. This template is used as the base layout for all other templates in the project. It includes the basic HTML structure, meta tags, and a placeholder for the main content. The purpose of this change is to provide a consistent and reusable base layout for all pages in the project, reducing code duplication and improving maintainability. --- feat(layouts): add single.html layout template This commit adds a new layout template called single.html. This template is used for rendering individual content pages. It includes a block for the main content and some additional logic for handling the current menu item and generating image JSON. The purpose of this change is to provide a specific layout for individual content pages, allowing for customization and flexibility in their presentation. --- refactor(layouts): remove index.html layout template and related partials This commit removes the index.html layout template and its associated partials (footer.html, head.html, link.html, meta.html, seo.html, mobile_wrapper.html, and nav.html). The index.html layout template was no longer needed as the project has transitioned to using the baseof.html and single.html templates for rendering pages. The associated partials were also no longer used and can be safely removed. The purpose of this change is to clean up unused code and reduce clutter in the project. --- layouts/_default/baseof.html | 17 ++++++++ layouts/_default/single.html | 14 +++++++ layouts/index.html | 42 ------------------- layouts/partials/footer.html | 24 ----------- layouts/partials/head.html | 13 ------ layouts/partials/head/link.html | 27 ++++++++++++ layouts/partials/head/meta.html | 1 + .../partials/{header.html => head/seo.html} | 0 layouts/partials/mobile_wrapper.html | 6 --- layouts/partials/nav.html | 16 +++++-- 10 files changed, 71 insertions(+), 89 deletions(-) create mode 100644 layouts/_default/baseof.html create mode 100644 layouts/_default/single.html delete mode 100644 layouts/index.html delete mode 100644 layouts/partials/footer.html delete mode 100644 layouts/partials/head.html create mode 100644 layouts/partials/head/link.html create mode 100644 layouts/partials/head/meta.html rename layouts/partials/{header.html => head/seo.html} (100%) delete mode 100644 layouts/partials/mobile_wrapper.html diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html new file mode 100644 index 0000000..729a235 --- /dev/null +++ b/layouts/_default/baseof.html @@ -0,0 +1,17 @@ + + + + + + {{ .Title }} + {{- partial "head/link.html" -}} + {{- partial "head/meta.html" -}} + {{- partial "head/seo.html" -}} + + +
+ {{- block "main" . -}} + {{- end -}} +
+ + diff --git a/layouts/_default/single.html b/layouts/_default/single.html new file mode 100644 index 0000000..622601d --- /dev/null +++ b/layouts/_default/single.html @@ -0,0 +1,14 @@ +{{- define "main" -}} + {{- $params := .Scratch.Get "params" -}} + {{- $currentPage := . -}} + {{- with partial "function/currentMenuItem.html" . -}} + {{- partial "resources/imageJSON.html" (dict "Path" .Name "Page" $currentPage) -}} + + {{- end -}} +
+ {{- partial "nav.html" . -}} +
+
+ {{ .Content }} +
+{{- end -}} diff --git a/layouts/index.html b/layouts/index.html deleted file mode 100644 index 5e9a693..0000000 --- a/layouts/index.html +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - {{ partial "head.html" . }} - {{ .Title }} - - -
- {{ partial "header.html" . }} -
-
- {{ $sourcePath := "images" }} - {{ $gallery := site.GetPage $sourcePath }} - {{ with $gallery.Resources.ByType "image" }} - {{ $index := len . }} - {{ $.Scratch.Add "img" slice }} - {{ range . }} - {{ $index = sub $index 1 }} - {{ $colors := .Colors }} - {{ $pColor := index $colors 0 }} - {{ $sColor := "#ccc" }} - {{ if gt (len $colors) 1 }} - {{ $sColor = index $colors 1 }} - {{ end }} - {{ $resize := .Resize "x2000 webp Lanczos q70" }} - {{ $.Scratch.Add "img" (dict - "index" (int $index) - "url" (string .RelPermalink) - "imgH" (int .Height) - "imgW" (int .Width) - "pColor" (string $pColor) - "sColor" (string $sColor)) - }} - {{ end }} - - {{ end }} -
-
{{ partial "nav.html" . }}
- - diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html deleted file mode 100644 index 6029f5d..0000000 --- a/layouts/partials/footer.html +++ /dev/null @@ -1,24 +0,0 @@ - - - - \ No newline at end of file diff --git a/layouts/partials/head.html b/layouts/partials/head.html deleted file mode 100644 index 44d92c6..0000000 --- a/layouts/partials/head.html +++ /dev/null @@ -1,13 +0,0 @@ -{{- $fingerprint := .Scratch.Get "fingerprint" | default "" -}} -{{- $style := dict "Source" "scss/style.scss" "Fingerprint" $fingerprint -}} -{{- $options := dict "targetPath" "css/style.min.css" "enableSourceMap" true -}} -{{- $style = dict "Context" . "ToCSS" $options | merge $style -}} -{{- partial "plugin/style.html" $style -}} -{{- $esBuildOpts := dict "minify" hugo.IsProduction -}} - -{{- $script := resources.Get "ts/main.ts" | js.Build $esBuildOpts -}} - - diff --git a/layouts/partials/head/link.html b/layouts/partials/head/link.html new file mode 100644 index 0000000..e890346 --- /dev/null +++ b/layouts/partials/head/link.html @@ -0,0 +1,27 @@ +{{/* fingerprint */}} +{{- $fingerprint := .Scratch.Get "fingerprint" | default "" -}} + +{{/* main style */}} +{{- $style := dict "Source" "scss/style.scss" "Fingerprint" $fingerprint -}} +{{- $options := dict "targetPath" "css/style.min.css" "enableSourceMap" true -}} +{{- $style = dict "Context" . "ToCSS" $options | merge $style -}} +{{- partial "plugin/style.html" $style -}} + +{{/* swiper css */}} +{{- $style := dict "Source" "/lib/swiper/swiper-bundle.min.css" "Fingerprint" $fingerprint -}} +{{- partial "plugin/style.html" $style -}} + +{{/* main js */}} +{{- $esBuildOpts := dict "minify" hugo.IsProduction -}} +{{- $js := resources.Get "ts/main.ts" | js.Build $esBuildOpts -}} +{{- $script := dict "Source" $js.Permalink "Fingerprint" $fingerprint "Defer" true -}} +{{- partial "plugin/script.html" $script -}} + +{{/* fonts */}} + diff --git a/layouts/partials/head/meta.html b/layouts/partials/head/meta.html new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/layouts/partials/head/meta.html @@ -0,0 +1 @@ + diff --git a/layouts/partials/header.html b/layouts/partials/head/seo.html similarity index 100% rename from layouts/partials/header.html rename to layouts/partials/head/seo.html diff --git a/layouts/partials/mobile_wrapper.html b/layouts/partials/mobile_wrapper.html deleted file mode 100644 index 940371f..0000000 --- a/layouts/partials/mobile_wrapper.html +++ /dev/null @@ -1,6 +0,0 @@ -
- {{ $sourcePath := "images" }} - {{ $gallery := site.GetPage $sourcePath }} - {{ with $gallery.Resources.ByType "image" }} - {{ end }} -
\ No newline at end of file diff --git a/layouts/partials/nav.html b/layouts/partials/nav.html index f1b9a4a..d1fb87d 100644 --- a/layouts/partials/nav.html +++ b/layouts/partials/nav.html @@ -3,10 +3,18 @@ Bridget Baker
Threshold: