From 5750079022f6743a2fc380bf54bfed51afd7788a Mon Sep 17 00:00:00 2001
From: Cell <1024@lruihao.cn>
Date: Mon, 12 Sep 2022 19:42:44 +0800
Subject: [PATCH] :recycle: Refactor: plugin script
---
CHANGELOG.md | 1 +
layouts/partials/plugin/script.html | 32 +++++++++++++++++++++--------
2 files changed, 25 insertions(+), 8 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0dab88ec5..6f3afbbdb 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -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
diff --git a/layouts/partials/plugin/script.html b/layouts/partials/plugin/script.html
index 78cdede6b..172de517d 100644
--- a/layouts/partials/plugin/script.html
+++ b/layouts/partials/plugin/script.html
@@ -1,11 +1,11 @@
-{{- if .Content -}}
-
-{{- else if strings.HasPrefix .Source "
{{- else -}}
- {{- $src := .Source -}}
- {{- $integrity := .Integrity -}}
- {{- if $src -}}
+ {{- if strings.HasPrefix .Source "
+ {{- $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 -}}
+
{{- end -}}
{{- end -}}