fix hightlight-js partial

Inline script should not be inserted on page if site-level
highlightjs setting is false.
This commit is contained in:
Evgeny Kuznetsov 2020-04-04 08:59:41 +03:00
parent 80fe1bf4a9
commit 073456b675
No known key found for this signature in database
GPG key ID: 79B2B092A63F5E6F

View file

@ -1,13 +1,12 @@
{{- if (.Site.Params.highlightjs) -}}
{{ if or ((not (isset .Params "highlight")) and ((isset .Params "highlight") .Params.highlight)) }}
{{ $.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>
{{ with $.Scratch.Get "hl_languages" }}
{{ range . }}
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.13.1/languages/{{.}}.min.js"></script>
{{ end }}
{{ end }}
{{ end }}
<script type="text/javascript">
{{ with $.Scratch.Get "hl_languages" }}
hljs.configure({languages: [{{(delimit . ", ")}}]});
@ -16,3 +15,4 @@
</script>
{{ $.Scratch.Delete "hl_languages" }}
{{ end }}
{{- end -}}