Make sure CSS files are only included once

This commit is contained in:
Eryn Wells 2022-10-15 10:02:28 -07:00
parent 9db95c7bb0
commit 9e72b74200

View file

@ -28,14 +28,22 @@
<link rel="stylesheet" as="style" href="/styles/development.css">
{{ end }}
{{ block "styles" . }}{{ end }}
{{ if not .FirstSection.IsHome }}
{{ range .FirstSection.Resources.Match "*.css" }}
{{- $includedCSS := slice -}}
{{- if not .FirstSection.IsHome -}}
{{- range .FirstSection.Resources.Match "*.css" -}}
{{- if not (in $includedCSS .Permalink) -}}
{{- $includedCSS = $includedCSS | append .Permalink -}}
<link rel="stylesheet" as="style" href="{{ .Permalink }}">
{{ end }}
{{ end }}
{{ range .Resources.Match "*.css" }}
{{- end -}}
{{- end -}}
{{- end -}}
{{- range .Resources.Match "*.css" -}}
{{- if not (in $includedCSS .Permalink) -}}
{{- $includedCSS = $includedCSS | append .Permalink -}}
<link rel="stylesheet" as="style" href="{{ .Permalink }}">
{{ end }}
{{- end -}}
{{- end -}}
{{ block "scripts" . }}{{ end }}