mirror of
https://github.com/hugo-fixit/FixIt.git
synced 2026-08-24 15:28:57 +00:00
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:
@@ -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 -}}
|
||||
|
||||
@@ -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 -}}
|
||||
|
||||
Reference in New Issue
Block a user