AMPERION_Webpage/layouts/partials/style.html

37 lines
1.4 KiB
HTML
Raw Normal View History

2025-09-08 01:15:11 +02:00
{{- /* Robust CSS loader: externe Links direkt, lokale Ressourcen sammeln, SCSS bauen, dann bündeln */ -}}
<!-- DNS prefetch on -->
2025-06-06 18:12:46 +02:00
<meta http-equiv="x-dns-prefetch-control" content="on">
2025-09-08 01:15:11 +02:00
{{- $bundleList := slice -}}
{{- /* 1) Plugins aus params: externe -> <link>, lokale -> sammeln */ -}}
{{- $plugins := site.Params.plugins.css | default (slice) -}}
{{- range $plugins }}
{{- $link := .link | default "" -}}
{{- if $link -}}
{{- if findRE `^https?://` $link -}}
<link rel="stylesheet" href="{{ $link }}" {{ .attributes | safeHTMLAttr }}>
{{- else -}}
{{- with (resources.Get $link) -}}
{{- $bundleList = $bundleList | append . -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- /* 2) SCSS bauen (falls vorhanden) und hinzufügen */ -}}
{{- with (resources.Get "scss/style.scss") -}}
{{- $css := . | resources.ExecuteAsTemplate "scss/style.scss" $ | toCSS (dict "targetPath" "css/style.css") -}}
{{- $bundleList = $bundleList | append $css -}}
{{- end -}}
2025-06-06 18:12:46 +02:00
2025-09-08 01:15:11 +02:00
{{- /* 3) Bündeln + minify + fingerprint, sofern wir was haben */ -}}
{{- if gt (len $bundleList) 0 -}}
{{- $bundle := $bundleList | resources.Concat "css/bundle.css" | minify | fingerprint "sha512" -}}
<link rel="stylesheet" href="{{ $bundle.RelPermalink }}" integrity="{{ $bundle.Data.Integrity }}">
{{- else -}}
{{- /* Fallback: statische CSS falls vorhanden/gewünscht */ -}}
<link rel="stylesheet" href="{{ "css/style.css" | relURL }}">
{{- end -}}