Files
bridget/layouts/partials/plugin/style.html
Sped0n df5d839074 chore(link.html): update critical style source and options to improve performance and maintainability
chore(link.html): update main style source and options to improve performance and maintainability
chore(link.html): remove unused meta.html file
chore(nav.html): update decrement and increment buttons to use Unicode characters for better accessibility
chore(plugin/style.html): update style plugin to support inline styles for critical CSS
chore(plugin/style.html): update style plugin to support minification and fingerprinting for main CSS
chore(plugin/style.html): remove script plugin as it is no longer used
chore(plugin/style.html): update style plugin to support inline styles for critical CSS
chore(plugin/style.html): update style plugin to support minification and fingerprinting for main CSS
chore(resources/imageJSON.html): update image resize options for better performance and quality
2023-11-01 23:09:53 +08:00

60 lines
1.9 KiB
HTML

{{- if strings.HasPrefix .Source "<link" -}}
{{- safeHTML .Source -}}
{{- else -}}
{{- $href := .Source -}}
{{- $integrity := .Integrity -}}
{{- $resource := 0 -}}
{{- if $href | and (not (urls.Parse $href).Host) -}}
{{- $resource = resources.Get $href -}}
{{- end -}}
{{- with .Content -}}
{{- $resource = resources.FromString $.Path . -}}
{{- end -}}
{{- if $resource -}}
{{- with .Template -}}
{{- $resource = $resource | resources.ExecuteAsTemplate . $.Context -}}
{{- end -}}
{{- with .ToCSS -}}
{{- $options := . | merge (dict "outputStyle" "compressed") -}}
{{- $resource = $resource | toCSS $options -}}
{{- end -}}
{{- if or .Minify .Inline -}}
{{- $resource = $resource | minify -}}
{{- end -}}
{{- with .Fingerprint -}}
{{- $resource = $resource | fingerprint . -}}
{{- $integrity = $resource.Data.Integrity -}}
{{- end -}}
{{- $href = $resource.RelPermalink -}}
{{- end -}}
{{- if .Inline -}}
<style>{{- $resource.Content | safeCSS -}}</style>
{{- else if .Defer -}}
<link
rel="preload"
as="style"
onload="this.onload=null;this.rel='stylesheet'"
href="{{ $href }}"
{{ if .Crossorigin }}crossorigin="anonymous"{{ end }}{{ with $integrity }}
integrity="{{ . }}"
{{ end }}{{ with .Attr }}{{ . | safeHTMLAttr }}{{ end }}
/>
<noscript
><link
rel="stylesheet"
href="{{ $href }}"
{{ if .Crossorigin }}crossorigin="anonymous"{{ end }}{{ with $integrity }}
integrity="{{ . }}"
{{ end }}{{ with .Attr }}{{ . | safeHTMLAttr }}{{ end }}
/></noscript>
{{- else -}}
<link
rel="stylesheet"
href="{{ $href }}"
{{ if .Crossorigin }}crossorigin="anonymous"{{ end }}{{ with $integrity }}
integrity="{{ . }}"
{{ end }}{{ with .Attr }}{{ . | safeHTMLAttr }}{{ end }}
/>
{{- end -}}
{{- end -}}