mirror of
https://github.com/hugo-fixit/FixIt.git
synced 2026-08-24 23:38:56 +00:00
♻️ Refactor: plugin script
This commit is contained in:
@@ -24,6 +24,7 @@ All notable changes to this project will be documented in this file.
|
||||
- :recycle: Refactor: back to top and scroll to comments
|
||||
- :recycle: Refactor: custom.js rendering and remove `params.customJS` ([#189](https://github.com/hugo-fixit/FixIt/pull/189))
|
||||
- :recycle: Refactor: scss directory ([#185](https://github.com/hugo-fixit/FixIt/issues/185))
|
||||
- :recycle: Refactor: plugin script
|
||||
- :bug: Fix: add function `dos2unix` to unify new lines symbol between Windows and Unix/Mac OS
|
||||
- :bug: Fix: author display error in post and markdown file
|
||||
- :bug: Fix: use data attributes or class replace for custom attributes
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
{{- if .Content -}}
|
||||
<script>{{- .Content | safeJS -}}</script>
|
||||
{{- else if strings.HasPrefix .Source "<script" -}}
|
||||
{{- safeHTML .Source -}}
|
||||
{{- with .Content -}}
|
||||
<script>{{ . | safeJS }}</script>
|
||||
{{- else -}}
|
||||
{{- $src := .Source -}}
|
||||
{{- $integrity := .Integrity -}}
|
||||
{{- if $src -}}
|
||||
{{- if strings.HasPrefix .Source "<script" -}}
|
||||
{{- safeHTML .Source -}}
|
||||
{{- else -}}
|
||||
{{- $src := .Source -}}
|
||||
{{- $integrity := .Integrity -}}
|
||||
{{- if (urls.Parse $src).Host | not -}}
|
||||
{{- $resource := resources.Get $src -}}
|
||||
{{- with .Template -}}
|
||||
@@ -20,6 +20,22 @@
|
||||
{{- end -}}
|
||||
{{- $src = $resource.RelPermalink -}}
|
||||
{{- end -}}
|
||||
<script src="{{ $src }}"{{ if .Crossorigin }} crossorigin="anonymous"{{ end }}{{ with $integrity }} integrity="{{ . }}"{{ end }}{{ if .Async }} async{{ end }}{{ if .Defer }} defer{{ end }}{{ with .Attr }} {{ . | safeHTMLAttr }}{{ end }}></script>
|
||||
{{- $attrs := printf `src="%v"` $src -}}
|
||||
{{- if .Crossorigin -}}
|
||||
{{- $attrs = ` crossorigin="anonymous"` | add $attrs -}}
|
||||
{{- end -}}
|
||||
{{- with $integrity -}}
|
||||
{{- $attrs = printf ` integrity="%v"` . | add $attrs -}}
|
||||
{{- end -}}
|
||||
{{- if .Async -}}
|
||||
{{- $attrs = " async" | add $attrs -}}
|
||||
{{- end -}}
|
||||
{{- if .Defer -}}
|
||||
{{- $attrs = " defer" | add $attrs -}}
|
||||
{{- end -}}
|
||||
{{- with .Attr -}}
|
||||
{{- $attrs = add " " . | add $attrs -}}
|
||||
{{- end -}}
|
||||
<script {{ $attrs | safeHTMLAttr }}></script>
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
Reference in New Issue
Block a user