forked from markus/AMPERION_Webpage
36 lines
1.4 KiB
HTML
36 lines
1.4 KiB
HTML
{{- /* Robust CSS loader: externe Links direkt, lokale Ressourcen sammeln, SCSS bauen, dann bündeln */ -}}
|
|
|
|
<!-- DNS prefetch on -->
|
|
<meta http-equiv="x-dns-prefetch-control" content="on">
|
|
|
|
{{- $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 -}}
|
|
|
|
{{- /* 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 -}}
|