From a0ab272f7d22d1ca4dc9a6ceb467a1f6d8dcd8ae Mon Sep 17 00:00:00 2001 From: Dillon Date: Wed, 22 Apr 2020 01:00:51 +0800 Subject: [PATCH] fix: fix script CORS error (#246) --- layouts/partials/assets.html | 54 +++++++++++++++++------------------ layouts/partials/comment.html | 12 ++++---- 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/layouts/partials/assets.html b/layouts/partials/assets.html index d8952a0b..c8f6ee61 100644 --- a/layouts/partials/assets.html +++ b/layouts/partials/assets.html @@ -12,7 +12,7 @@ {{- /* iconfont */ -}} {{- if (.Scratch.Get "this").iconfont -}} {{- with $cdn.iconfontCSS -}} - {{- dict "source" . "crossorigin" true | dict "scratch" $.Scratch "data" | partial "scratch/stylesheet.html" -}} + {{- dict "source" . | dict "scratch" $.Scratch "data" | partial "scratch/stylesheet.html" -}} {{- else -}} {{- dict "source" "lib/iconfont/iconfont.css" "minify" true "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/stylesheet.html" -}} {{- end -}} @@ -20,7 +20,7 @@ {{- /* Smooth Scroll */ -}} {{- with $cdn.smoothScrollJS -}} - {{- dict "source" . "crossorigin" true | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} + {{- dict "source" . | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} {{- else -}} {{- dict "source" "lib/smooth-scroll/smooth-scroll.min.js" "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} {{- end -}} @@ -28,7 +28,7 @@ {{- /* Search */ -}} {{- if .Site.Params.search.enable -}} {{- with $cdn.autocompleteJS -}} - {{- dict "source" . "crossorigin" true | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} + {{- dict "source" . | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} {{- else -}} {{- dict "source" "lib/autocomplete/autocomplete.min.js" "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} {{- end -}} @@ -38,7 +38,7 @@ {{- $searchConfig = dict "type" "lunr" "lunrIndexURL" .RelPermalink | merge $searchConfig -}} {{- end -}} {{- with $cdn.lunrJS -}} - {{- dict "source" . "crossorigin" true | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} + {{- dict "source" . | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} {{- else -}} {{- dict "source" "lib/lunr/lunr.min.js" "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} {{- end -}} @@ -52,7 +52,7 @@ {{- end -}} {{- else if eq .Site.Params.search.type "algolia" -}} {{- with $cdn.algoliasearchJS -}} - {{- dict "source" . "crossorigin" true | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} + {{- dict "source" . | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} {{- else -}} {{- dict "source" "lib/algoliasearch/algoliasearch-lite.umd.min.js" "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} {{- end -}} @@ -63,7 +63,7 @@ {{- /* lazysizes */ -}} {{- with $cdn.lazysizesJS -}} - {{- dict "source" . "crossorigin" true | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} + {{- dict "source" . | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} {{- else -}} {{- dict "source" "lib/lazysizes/lazysizes.min.js" "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} {{- end -}} @@ -71,22 +71,22 @@ {{- /* lightgallery.js */ -}} {{- if $params.lightgallery -}} {{- with $cdn.lightgalleryCSS -}} - {{- dict "source" . "crossorigin" true | dict "scratch" $.Scratch "data" | partial "scratch/stylesheet.html" -}} + {{- dict "source" . | dict "scratch" $.Scratch "data" | partial "scratch/stylesheet.html" -}} {{- else -}} {{- dict "source" "lib/lightgallery/lightgallery.min.css" "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/stylesheet.html" -}} {{- end -}} {{- with $cdn.lightgalleryJS -}} - {{- dict "source" . "crossorigin" true | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} + {{- dict "source" . | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} {{- else -}} {{- dict "source" "lib/lightgallery/lightgallery.min.js" "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} {{- end -}} {{- with $cdn.lightgalleryThumbnailJS -}} - {{- dict "source" . "crossorigin" true | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} + {{- dict "source" . | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} {{- else -}} {{- dict "source" "lib/lightgallery/lg-thumbnail.min.js" "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} {{- end -}} {{- with $cdn.lightgalleryZoomJS -}} - {{- dict "source" . "crossorigin" true | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} + {{- dict "source" . | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} {{- else -}} {{- dict "source" "lib/lightgallery/lg-zoom.min.js" "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} {{- end -}} @@ -97,7 +97,7 @@ {{- /* clipboard.js */ -}} {{- if ne $params.copycode false -}} {{- with $cdn.clipboardJS -}} - {{- dict "source" . "crossorigin" true | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} + {{- dict "source" . | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} {{- else -}} {{- dict "source" "lib/clipboard/clipboard.min.js" "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} {{- end -}} @@ -107,7 +107,7 @@ {{- /* Sharer.js */ -}} {{- if $params.share.enable -}} {{- with $cdn.sharerJS -}} - {{- dict "source" . "crossorigin" true | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} + {{- dict "source" . | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} {{- else -}} {{- dict "source" "lib/sharer/sharer.min.js" "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} {{- end -}} @@ -116,7 +116,7 @@ {{- /* TypeIt */ -}} {{- with (.Scratch.Get "this").typeitMap -}} {{- with $cdn.typeitJS -}} - {{- dict "source" . "crossorigin" true | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} + {{- dict "source" . | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} {{- else -}} {{- dict "source" "lib/typeit/typeit.min.js" "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} {{- end -}} @@ -130,36 +130,36 @@ {{- /* KaTeX */ -}} {{- if $params.math.enable -}} {{- with $cdn.katexCSS -}} - {{- dict "source" . "crossorigin" true | dict "scratch" $.Scratch "data" | partial "scratch/stylesheet.html" -}} + {{- dict "source" . | dict "scratch" $.Scratch "data" | partial "scratch/stylesheet.html" -}} {{- else -}} {{- dict "source" "lib/katex/katex.min.css" "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/stylesheet.html" -}} {{- end -}} {{- with $cdn.katexJS -}} - {{- dict "source" . "crossorigin" true | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} + {{- dict "source" . | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} {{- else -}} {{- dict "source" "lib/katex/katex.min.js" "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} {{- end -}} {{- with $cdn.katexAutoRenderJS -}} - {{- dict "source" . "crossorigin" true | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} + {{- dict "source" . | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} {{- else -}} {{- dict "source" "lib/katex/auto-render.min.js" "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} {{- end -}} {{- $math := $params.math -}} {{- if $math.copyTex -}} {{- with $cdn.katexCopyTexCSS -}} - {{- dict "source" . "crossorigin" true | dict "scratch" $.Scratch "data" | partial "scratch/stylesheet.html" -}} + {{- dict "source" . | dict "scratch" $.Scratch "data" | partial "scratch/stylesheet.html" -}} {{- else -}} {{- dict "source" "lib/katex/copy-tex.min.css" "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/stylesheet.html" -}} {{- end -}} {{- with $cdn.katexCopyTexJS -}} - {{- dict "source" . "crossorigin" true | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} + {{- dict "source" . | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} {{- else -}} {{- dict "source" "lib/katex/copy-tex.min.js" "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} {{- end -}} {{- end -}} {{- if $math.mhchem -}} {{- with $cdn.katexMhchemJS -}} - {{- dict "source" . "crossorigin" true | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} + {{- dict "source" . | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} {{- else -}} {{- dict "source" "lib/katex/mhchem.min.js" "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} {{- end -}} @@ -180,7 +180,7 @@ {{- /* mermaid */ -}} {{- if (.Scratch.Get "this").mermaid -}} {{- with $cdn.mermaidJS -}} - {{- dict "source" . "crossorigin" true | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} + {{- dict "source" . | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} {{- else -}} {{- dict "source" "lib/mermaid/mermaid.min.js" "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} {{- end -}} @@ -191,12 +191,12 @@ {{- /* ECharts */ -}} {{- if (.Scratch.Get "this").echarts -}} {{- with $cdn.echartsJS -}} - {{- dict "source" . "crossorigin" true | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} + {{- dict "source" . | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} {{- else -}} {{- dict "source" "lib/echarts/echarts.min.js" "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} {{- end -}} {{- with $cdn.echartsMacaronsJS -}} - {{- dict "source" . "crossorigin" true | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} + {{- dict "source" . | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} {{- else -}} {{- dict "source" "lib/echarts/macarons.js" "minify" true "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} {{- end -}} @@ -205,12 +205,12 @@ {{- /* Mapbox GL */ -}} {{- if (.Scratch.Get "this").mapbox -}} {{- with $cdn.mapboxGLCSS -}} - {{- dict "source" . "crossorigin" true | dict "scratch" $.Scratch "data" | partial "scratch/stylesheet.html" -}} + {{- dict "source" . | dict "scratch" $.Scratch "data" | partial "scratch/stylesheet.html" -}} {{- else -}} {{- dict "source" "lib/mapbox-gl/mapbox-gl.min.css" "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/stylesheet.html" -}} {{- end -}} {{- with $cdn.mapboxGLJS -}} - {{- dict "source" . "crossorigin" true | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} + {{- dict "source" . | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} {{- else -}} {{- dict "source" "lib/mapbox-gl/mapbox-gl.min.js" "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} {{- end -}} @@ -222,21 +222,21 @@ {{- if (.Scratch.Get "this").music -}} {{- /* APlayer */ -}} {{- with $cdn.aplayerCSS -}} - {{- dict "source" . "crossorigin" true | dict "scratch" $.Scratch "data" | partial "scratch/stylesheet.html" -}} + {{- dict "source" . | dict "scratch" $.Scratch "data" | partial "scratch/stylesheet.html" -}} {{- else -}} {{- dict "source" "lib/aplayer/APlayer.min.css" "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/stylesheet.html" -}} {{- end -}} {{- $options := dict "targetPath" "lib/aplayer/dark.min.css" -}} {{- dict "source" "lib/aplayer/dark.scss" "toCSS" $options "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/stylesheet.html" -}} {{- with $cdn.aplayerJS -}} - {{- dict "source" . "crossorigin" true | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} + {{- dict "source" . | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} {{- else -}} {{- dict "source" "lib/aplayer/APlayer.min.js" "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} {{- end -}} {{- /* MetingJS */ -}} {{- with $cdn.metingJS -}} - {{- dict "source" . "crossorigin" true | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} + {{- dict "source" . | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} {{- else -}} {{- dict "source" "lib/meting/Meting.min.js" "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} {{- end -}} diff --git a/layouts/partials/comment.html b/layouts/partials/comment.html index bd525203..33e37e1d 100644 --- a/layouts/partials/comment.html +++ b/layouts/partials/comment.html @@ -9,7 +9,7 @@ {{- if $comment.disqus.enable -}}
{{- $source := printf "https://%s.disqus.com/embed.js" $comment.disqus.shortname -}} - {{- dict "source" $source "defer" true "crossorigin" true | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} + {{- dict "source" $source "defer" true | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} @@ -19,12 +19,12 @@ {{- if $comment.gitalk.enable -}}
{{- with $cdn.gitalkCSS -}} - {{- dict "source" . "crossorigin" true | dict "scratch" $.Scratch "data" | partial "scratch/stylesheet.html" -}} + {{- dict "source" . | dict "scratch" $.Scratch "data" | partial "scratch/stylesheet.html" -}} {{- else -}} {{- dict "source" "lib/gitalk/gitalk.css" "minify" true "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/stylesheet.html" -}} {{- end -}} {{- with $cdn.gitalkJS -}} - {{- dict "source" . "crossorigin" true | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} + {{- dict "source" . | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} {{- else -}} {{- dict "source" "lib/gitalk/gitalk.min.js" "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} {{- end -}} @@ -40,7 +40,7 @@ {{- $options := dict "targetPath" "lib/valine/valine.min.css" -}} {{- dict "source" "lib/valine/valine.scss" "toCSS" $options | dict "scratch" $.Scratch "data" | partial "scratch/stylesheet.html" -}} {{- with $cdn.valineJS -}} - {{- dict "source" . "crossorigin" true | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} + {{- dict "source" . | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} {{- else -}} {{- dict "source" "lib/valine/Valine.min.js" "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} {{- end -}} @@ -69,7 +69,7 @@ data-numposts="{{ $comment.facebook.numPosts }}" > {{- $source := printf "https://connect.facebook.net/%s/sdk.js#xfbml=1&version=v5.0&appId=%s&autoLogAppEvents=1" ($comment.facebook.languageCode | default (T "facebookLanguageCode")) $comment.facebook.appId -}} - {{- dict "source" $source "defer" true "crossorigin" true | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} + {{- dict "source" $source "defer" true | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} @@ -95,7 +95,7 @@ {{- if $comment.telegram.outlined -}} {{- $attr = printf `%s data-outlined="1"` $attr -}} {{- end -}} - {{- dict "source" "https://comments.app/js/widget.js?2" "defer" true "crossorigin" true "attr" $attr | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} + {{- dict "source" "https://comments.app/js/widget.js?2" "defer" true "attr" $attr | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}}