Merge pull request #117 from nekr0z/highlight-js

fix highlight-js partial
This commit is contained in:
Huy Tran 2020-06-05 15:47:30 +10:00 committed by GitHub
commit 7570de8eb4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,13 +1,12 @@
{{ if (isset .Params "highlight") }}
{{- 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>
<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 -}}