From 4327d34827c40f023f09b512cc589c83df0b4128 Mon Sep 17 00:00:00 2001 From: Eryn Wells Date: Fri, 28 Jun 2024 09:07:33 -0700 Subject: [PATCH] Clean up the partials directory Sort partials into base and site directories --- .../{design/system_css.html => base/css.html} | 0 layouts/partials/base/head.html | 5 ++ layouts/partials/base/head/css.html | 9 ++++ layouts/partials/base/head/js.html | 12 +++++ layouts/partials/menu.html | 51 +++++++++++++++++++ layouts/partials/site/footer.html | 5 ++ layouts/partials/site/header.html | 4 ++ layouts/partials/size_scale.html | 10 ---- 8 files changed, 86 insertions(+), 10 deletions(-) rename layouts/partials/{design/system_css.html => base/css.html} (100%) create mode 100644 layouts/partials/base/head.html create mode 100644 layouts/partials/base/head/css.html create mode 100644 layouts/partials/base/head/js.html create mode 100644 layouts/partials/menu.html create mode 100644 layouts/partials/site/footer.html create mode 100644 layouts/partials/site/header.html delete mode 100644 layouts/partials/size_scale.html diff --git a/layouts/partials/design/system_css.html b/layouts/partials/base/css.html similarity index 100% rename from layouts/partials/design/system_css.html rename to layouts/partials/base/css.html diff --git a/layouts/partials/base/head.html b/layouts/partials/base/head.html new file mode 100644 index 0000000..1b31af0 --- /dev/null +++ b/layouts/partials/base/head.html @@ -0,0 +1,5 @@ + + +{{ if .IsHome }}{{ site.Title }}{{ else }}{{ printf "%s | %s" .Title site.Title }}{{ end }} +{{ partialCached "base/head/css.html" . }} +{{ partialCached "base/head/js.html" . }} diff --git a/layouts/partials/base/head/css.html b/layouts/partials/base/head/css.html new file mode 100644 index 0000000..55425b7 --- /dev/null +++ b/layouts/partials/base/head/css.html @@ -0,0 +1,9 @@ +{{- with (partial "base/css.html" .) }} + {{- if eq hugo.Environment "development" }} + + {{- else }} + {{- with . | minify | fingerprint }} + + {{- end }} + {{- end }} +{{- end }} diff --git a/layouts/partials/base/head/js.html b/layouts/partials/base/head/js.html new file mode 100644 index 0000000..18fe842 --- /dev/null +++ b/layouts/partials/base/head/js.html @@ -0,0 +1,12 @@ +{{- with resources.Get "js/main.js" }} + {{- if eq hugo.Environment "development" }} + {{- with . | js.Build }} + + {{- end }} + {{- else }} + {{- $opts := dict "minify" true }} + {{- with . | js.Build $opts | fingerprint }} + + {{- end }} + {{- end }} +{{- end }} diff --git a/layouts/partials/menu.html b/layouts/partials/menu.html new file mode 100644 index 0000000..2bf8a68 --- /dev/null +++ b/layouts/partials/menu.html @@ -0,0 +1,51 @@ +{{- /* +Renders a menu for the given menu ID. + +@context {page} page The current page. +@context {string} menuID The menu ID. + +@example: {{ partial "menu.html" (dict "menuID" "main" "page" .) }} +*/}} + +{{- $page := .page }} +{{- $menuID := .menuID }} + +{{- with index site.Menus $menuID }} + +{{- end }} + +{{- define "partials/inline/menu/walk.html" }} + {{- $page := .page }} + {{- range .menuEntries }} + {{- $attrs := dict "href" .URL }} + {{- if $page.IsMenuCurrent .Menu . }} + {{- $attrs = merge $attrs (dict "class" "active" "aria-current" "page") }} + {{- else if $page.HasMenuCurrent .Menu .}} + {{- $attrs = merge $attrs (dict "class" "ancestor" "aria-current" "true") }} + {{- end }} + {{- $name := .Name }} + {{- with .Identifier }} + {{- with T . }} + {{- $name = . }} + {{- end }} + {{- end }} +
  • + {{ $name }} + {{- with .Children }} + + {{- end }} +
  • + {{- end }} +{{- end }} diff --git a/layouts/partials/site/footer.html b/layouts/partials/site/footer.html new file mode 100644 index 0000000..8509544 --- /dev/null +++ b/layouts/partials/site/footer.html @@ -0,0 +1,5 @@ + diff --git a/layouts/partials/site/header.html b/layouts/partials/site/header.html new file mode 100644 index 0000000..a3f5c33 --- /dev/null +++ b/layouts/partials/site/header.html @@ -0,0 +1,4 @@ +
    + + {{ partial "menu.html" (dict "menuID" "main" "page" .) }} +
    diff --git a/layouts/partials/size_scale.html b/layouts/partials/size_scale.html deleted file mode 100644 index 68d05fd..0000000 --- a/layouts/partials/size_scale.html +++ /dev/null @@ -1,10 +0,0 @@ -{{- $scale := slice - (dict "Name" "xxs" "Value" -3) - (dict "Name" "xs" "Value" -2) - (dict "Name" "s" "Value" -1) - (dict "Name" "m" "Value" 0) - (dict "Name" "l" "Value" 1) - (dict "Name" "xl" "Value" 2) - (dict "Name" "xxl" "Value" 3) --}} -{{ return $scale }}