Fixing hightlight-js embedding error 'hljs is not defined' when highlightjs is not configured in hugo

This commit is contained in:
Julian Stier 2020-03-24 19:54:14 +01:00
parent 3520ff123d
commit 5046967a61

View file

@ -7,12 +7,12 @@
<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 . ", ")}}]});
{{ end }}
hljs.initHighlightingOnLoad();
</script>
{{ end }}
{{ $.Scratch.Delete "hl_languages" }}
{{ end }}