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,11 @@
{{ $processedResources := slice }}
{{ range $r := resources.Match "css/*.css" }}
{{
$processedResources = append
(resources.Get $r | resources.ExecuteAsTemplate $r (dict "Page" $))
$processedResources
}}
{{ end }}
{{ $css := $processedResources | resources.Concat "css/base.css" }}
{{ return $css }}

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