fix(layouts): fix Content+Path code path in style/script plugin partials

- style.html: Content+Path now uses to-css.html for proper SCSS compilation
- script.html: Content+Path now uses js-build.html with Build/Minify/Fingerprint
- Both paths now update integrity hash for SRI support
- script.html: restructured fallback logic to match style.html pattern
This commit is contained in:
Cell
2026-06-27 21:57:46 +08:00
parent ea140e35f8
commit d076ebf2e1
2 changed files with 13 additions and 11 deletions
+10 -9
View File
@@ -24,7 +24,7 @@
{{- $src := "" -}}
{{- $integrity := .Integrity -}}
{{- /* Pre-built resource */ -}}
{{- /* Resource (pre-built) */ -}}
{{- with .Resource -}}
{{- $src = .RelPermalink -}}
{{- with .Data.Integrity -}}
@@ -33,11 +33,8 @@
{{- end -}}
{{- /* Source build */ -}}
{{- if not $src -}}
{{- $src = .Source -}}
{{- end -}}
{{- if $src | and (not (urls.Parse $src).Host) | and (not .Resource) -}}
{{- $resource := resources.Get $src -}}
{{- if .Source | and (not .Resource) | and (not (urls.Parse .Source).Host) -}}
{{- $resource := resources.Get .Source -}}
{{- with .Template -}}
{{- $resource = resources.ExecuteAsTemplate . $.Context $resource -}}
{{- end -}}
@@ -50,15 +47,19 @@
{{- end -}}
{{- end -}}
{{- /* Script form string */ -}}
{{- /* Script from string */ -}}
{{- if .Content | and .Path -}}
{{- $contentResource := resources.FromString .Path .Content -}}
{{- if .Minify -}}
{{- $contentResource = $contentResource | minify -}}
{{- $contentResource = dict "Resource" $contentResource "Build" .Build "Minify" .Minify "Fingerprint" .Fingerprint | partial "function/js-build.html" -}}
{{- with .Fingerprint -}}
{{- $integrity = $contentResource.Data.Integrity -}}
{{- end -}}
{{- $src = $contentResource.RelPermalink -}}
{{- end -}}
{{- /* Fallback to source */ -}}
{{- $src = $src | default .Source -}}
{{- /* Script attributes */ -}}
{{- if $src -}}
{{- $attrs := printf `src="%v"` $src -}}
+3 -2
View File
@@ -47,8 +47,9 @@
{{- /* Style from string */ -}}
{{- if .Content | and .Path -}}
{{- $contentResource := resources.FromString .Path .Content -}}
{{- if .Minify -}}
{{- $contentResource = $contentResource | minify -}}
{{- $contentResource = dict "Resource" $contentResource "ToCSS" .ToCSS "Minify" .Minify "Fingerprint" .Fingerprint | partial "function/to-css.html" -}}
{{- with .Fingerprint -}}
{{- $integrity = $contentResource.Data.Integrity -}}
{{- end -}}
{{- $href = $contentResource.RelPermalink -}}
{{- end -}}