Skip to content
This repository was archived by the owner on Mar 9, 2022. It is now read-only.

Commit

Permalink
fix: fix script CORS error (#246)
Browse files Browse the repository at this point in the history
  • Loading branch information
dillonzq authored Apr 21, 2020
1 parent a5d0b9a commit a0ab272
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 33 deletions.
54 changes: 27 additions & 27 deletions layouts/partials/assets.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,23 @@
{{- /* 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 -}}
{{- end -}}

{{- /* 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 -}}

{{- /* 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 -}}
Expand All @@ -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 -}}
Expand All @@ -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 -}}
Expand All @@ -63,30 +63,30 @@

{{- /* 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 -}}

{{- /* 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 -}}
Expand All @@ -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 -}}
Expand All @@ -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 -}}
Expand All @@ -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 -}}
Expand All @@ -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 -}}
Expand All @@ -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 -}}
Expand All @@ -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 -}}
Expand All @@ -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 -}}
Expand All @@ -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 -}}
Expand Down
12 changes: 6 additions & 6 deletions layouts/partials/comment.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
{{- if $comment.disqus.enable -}}
<div id="disqus_thread" class="comment"></div>
{{- $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" -}}
<noscript>
Please enable JavaScript to view the comments powered by <a href="https://disqus.com/?ref_noscript">Disqus</a>.
</noscript>
Expand All @@ -19,12 +19,12 @@
{{- if $comment.gitalk.enable -}}
<div id="gitalk" class="comment"></div>
{{- 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 -}}
Expand All @@ -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 -}}
Expand Down Expand Up @@ -69,7 +69,7 @@
data-numposts="{{ $comment.facebook.numPosts }}"
></div>
{{- $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" -}}
<noscript>
Please enable JavaScript to view the comments powered by <a href="https://developers.facebook.com/docs/plugins/comments/"></a>Facebook</a>.
</noscript>
Expand All @@ -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" -}}
<noscript>
Please enable JavaScript to view the comments powered by <a href="https://comments.app/">Telegram Comments</a>.
</noscript>
Expand Down

0 comments on commit a0ab272

Please sign in to comment.