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

Commit

Permalink
fix(scripts): fix CDN not work bug
Browse files Browse the repository at this point in the history
  • Loading branch information
dillonzq committed Feb 7, 2020
1 parent 61250a0 commit a207005
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions layouts/partials/scripts.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,17 @@
{{- $smooth_scroll | safeHTML -}}

{{- /* TypeIt https://github.com/alexmacarthur/typeit */ -}}
{{- with .Scratch.Get "typeitMap" -}}
{{- if .Scratch.Get "typeitMap" -}}
{{- $typeit := "" -}}
{{- if eq (getenv "HUGO_ENV") "production" | and $.Site.Params.cdn.typeit_js -}}
{{- $typeit = $.Site.Params.cdn.typeit_js -}}
{{- if eq (getenv "HUGO_ENV") "production" | and .Site.Params.cdn.typeit_js -}}
{{- $typeit = .Site.Params.cdn.typeit_js -}}
{{- else -}}
{{- $res := resources.Get "js/lib/typeit/typeit.min.js" -}}
{{- $typeit = printf "<script src=\"%s\"></script>" $res.RelPermalink -}}
{{- end -}}
{{- $typeit | safeHTML -}}
{{- $typeitArr := slice -}}
{{- range $key, $val := . -}}
{{- range $key, $val := .Scratch.Get "typeitMap" -}}
{{- $typeitArr = $typeitArr | append (slice $val) -}}
{{- end -}}
<script>
Expand Down Expand Up @@ -126,7 +126,7 @@
{{- end -}}

{{- /* mermaid https://github.com/knsv/mermaid */ -}}
{{- with .Scratch.Get "mermaidMap" -}}
{{- if .Scratch.Get "mermaidMap" -}}
{{- $mermaid := "" -}}
{{- if eq (getenv "HUGO_ENV") "production" | and .Site.Params.cdn.mermaid_js -}}
{{- $mermaid = .Site.Params.cdn.mermaid_js -}}
Expand All @@ -138,7 +138,7 @@
{{- $mermaid = delimit (slice $mermaid $mermaidInit) "" -}}
{{- $mermaid | safeHTML -}}
<script>
{{- printf "window.mermaidMap=%s;" (jsonify .) | safeJS -}}
{{- printf "window.mermaidMap=%s;" (jsonify .Scratch.Get "mermaidMap") | safeJS -}}
</script>
{{- end -}}

Expand Down Expand Up @@ -174,7 +174,7 @@
{{- end -}}

{{- /* jQuery.countdown https://github.com/hilios/jQuery.countdown */ -}}
{{- with .Scratch.Get "countdownMap" -}}
{{- if .Scratch.Get "countdownMap" -}}
{{- $countdown := "" -}}
{{- if eq (getenv "HUGO_ENV") "production" | and .Site.Params.cdn.jquery_countdown_js -}}
{{- $countdown = .Site.Params.cdn.jquery_countdown_js -}}
Expand All @@ -184,14 +184,14 @@
{{- end -}}
{{- $countdown | safeHTML -}}
<script>
{{- printf "window.countdownMap=%s;" (jsonify .) | safeJS -}}
{{- printf "window.countdownMap=%s;" (jsonify .Scratch.Get "countdownMap") | safeJS -}}
</script>
{{- end -}}

{{- /* dev feature */ -}}
{{- if .Params.dev -}}
{{- /* ECharts https://github.com/apache/incubator-echarts */ -}}
{{- with .Scratch.Get "echartsMap" -}}
{{- if .Scratch.Get "echartsMap" -}}
{{- $echarts_js := "" -}}
{{- if eq (getenv "HUGO_ENV") "production" | and .Site.Params.cdn.echarts_js -}}
{{- $echarts_js = .Site.Params.cdn.echarts_js -}}
Expand All @@ -210,7 +210,7 @@
{{- $echarts | safeHTML -}}
<script>
window.echartsMap = {
{{- range $key, $var := . -}}
{{- range $key, $var := .Scratch.Get "echartsMap" -}}
{{- $key }}: {{ $var | safeJS -}},
{{- end -}}
};
Expand Down

0 comments on commit a207005

Please sign in to comment.