fix hightlight-js partial
Inline script should not be inserted on page if site-level highlightjs setting is false.
This commit is contained in:
parent
80fe1bf4a9
commit
073456b675
1 changed files with 3 additions and 3 deletions
|
@ -1,13 +1,12 @@
|
||||||
|
{{- if (.Site.Params.highlightjs) -}}
|
||||||
{{ if or ((not (isset .Params "highlight")) and ((isset .Params "highlight") .Params.highlight)) }}
|
{{ if or ((not (isset .Params "highlight")) and ((isset .Params "highlight") .Params.highlight)) }}
|
||||||
{{ $.Scratch.Set "hl_languages" (union (.Site.Params.highlightjslanguages) (.Params.highlightjslanguages)) }}
|
{{ $.Scratch.Set "hl_languages" (union (.Site.Params.highlightjslanguages) (.Params.highlightjslanguages)) }}
|
||||||
{{ if (.Site.Params.highlightjs) }}
|
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.13.1/highlight.min.js"></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.13.1/highlight.min.js"></script>
|
||||||
{{ with $.Scratch.Get "hl_languages" }}
|
{{ with $.Scratch.Get "hl_languages" }}
|
||||||
{{ range . }}
|
{{ range . }}
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.13.1/languages/{{.}}.min.js"></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.13.1/languages/{{.}}.min.js"></script>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
{{ with $.Scratch.Get "hl_languages" }}
|
{{ with $.Scratch.Get "hl_languages" }}
|
||||||
hljs.configure({languages: [{{(delimit . ", ")}}]});
|
hljs.configure({languages: [{{(delimit . ", ")}}]});
|
||||||
|
@ -16,3 +15,4 @@
|
||||||
</script>
|
</script>
|
||||||
{{ $.Scratch.Delete "hl_languages" }}
|
{{ $.Scratch.Delete "hl_languages" }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
{{- end -}}
|
||||||
|
|
Loading…
Reference in a new issue