feat(shortcode): add script shortcode (#359)
This commit is contained in:
29
layouts/partials/plugin/style.html
Normal file
29
layouts/partials/plugin/style.html
Normal file
@@ -0,0 +1,29 @@
|
||||
{{- if .content -}}
|
||||
<style>
|
||||
{{- .content | safeCSS -}}
|
||||
</style>
|
||||
{{- else if strings.HasPrefix .source "<link" -}}
|
||||
{{- safeHTML .source -}}
|
||||
{{- else -}}
|
||||
{{- $href := .source -}}
|
||||
{{- $integrity := .integrity -}}
|
||||
{{- if (urls.Parse $href).Host | not -}}
|
||||
{{- $res := resources.Get $href -}}
|
||||
{{- with .template -}}
|
||||
{{- $res = $res | resources.ExecuteAsTemplate . $.context -}}
|
||||
{{- end -}}
|
||||
{{- with .toCSS -}}
|
||||
{{- $options := . | merge (dict "outputStyle" "compressed") -}}
|
||||
{{- $res = $res | toCSS $options -}}
|
||||
{{- end -}}
|
||||
{{- if .minify -}}
|
||||
{{- $res = $res | minify -}}
|
||||
{{- end -}}
|
||||
{{- with .fingerprint -}}
|
||||
{{- $res = $res | fingerprint . -}}
|
||||
{{- $integrity = $res.Data.Integrity -}}
|
||||
{{- end -}}
|
||||
{{- $href = $res.RelPermalink -}}
|
||||
{{- end -}}
|
||||
<link rel="stylesheet" href="{{ $href }}"{{ if .crossorigin }} crossorigin="anonymous"{{ end }}{{ with $integrity }} integrity="{{ . }}"{{ end }}{{ with .attr }} {{ . | safeHTMLAttr }}{{ end }}>
|
||||
{{- end -}}
|
||||
Reference in New Issue
Block a user