Clean up the partials directory

Sort partials into base and site directories
This commit is contained in:
Eryn Wells 2024-06-28 09:07:33 -07:00
parent d73c779508
commit 4327d34827
8 changed files with 86 additions and 10 deletions

View file

@ -0,0 +1,5 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>{{ if .IsHome }}{{ site.Title }}{{ else }}{{ printf "%s | %s" .Title site.Title }}{{ end }}</title>
{{ partialCached "base/head/css.html" . }}
{{ partialCached "base/head/js.html" . }}

View file

@ -0,0 +1,9 @@
{{- with (partial "base/css.html" .) }}
{{- if eq hugo.Environment "development" }}
<link rel="stylesheet" href="{{ .RelPermalink }}">
{{- else }}
{{- with . | minify | fingerprint }}
<link rel="stylesheet" href="{{ .RelPermalink }}" integrity="{{ .Data.Integrity }}" crossorigin="anonymous">
{{- end }}
{{- end }}
{{- end }}

View file

@ -0,0 +1,12 @@
{{- with resources.Get "js/main.js" }}
{{- if eq hugo.Environment "development" }}
{{- with . | js.Build }}
<script src="{{ .RelPermalink }}"></script>
{{- end }}
{{- else }}
{{- $opts := dict "minify" true }}
{{- with . | js.Build $opts | fingerprint }}
<script src="{{ .RelPermalink }}" integrity="{{- .Data.Integrity }}" crossorigin="anonymous"></script>
{{- end }}
{{- end }}
{{- end }}

View file

@ -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 }}
<nav class="site-header__nav">
<ul>
{{- partial "inline/menu/walk.html" (dict "page" $page "menuEntries" .) }}
</ul>
</nav>
{{- 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 }}
<li>
<a
{{- range $k, $v := $attrs }}
{{- with $v }}
{{- printf " %s=%q" $k $v | safeHTMLAttr }}
{{- end }}
{{- end -}}
>{{ $name }}</a>
{{- with .Children }}
<ul>
{{- partial "inline/menu/walk.html" (dict "page" $page "menuEntries" .) }}
</ul>
{{- end }}
</li>
{{- end }}
{{- end }}

View file

@ -0,0 +1,5 @@
<div class="site-footer__container">
<aside class="site-footer__copyright">
<small>Copyright © {{ now.Year }} <a href="mailto:eryn@erynwells.me">Eryn Wells</a>. All rights reserved.<small>
</aside>
</div>

View file

@ -0,0 +1,4 @@
<div class="site-header__container">
<aside class="site-header__title"><a href="{{ ($.Site.GetPage "/").Permalink }}">{{ site.Title }}</a></aside>
{{ partial "menu.html" (dict "menuID" "main" "page" .) }}
</div>

View file

@ -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 }}