hugo-theme-hyde-hyde/layouts/partials/highlight-js.html

19 lines
872 B
HTML
Raw Permalink Normal View History

{{- if (.Site.Params.highlightjs) -}}
2020-06-05 05:50:51 +00:00
{{ if (or (not (isset .Params "highlight")) (and (isset .Params "highlight") .Params.highlight)) }}
{{ $.Scratch.Set "hl_languages" (union (.Site.Params.highlightjslanguages) (.Params.highlightjslanguages)) }}
2022-02-19 00:33:15 +00:00
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.4.0/highlight.min.js"></script>
{{ with $.Scratch.Get "hl_languages" }}
2018-08-15 00:20:23 +00:00
{{ range . }}
2022-02-19 00:33:15 +00:00
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.4.0/languages/{{.}}.min.js"></script>
2018-08-15 00:20:23 +00:00
{{ end }}
2018-08-15 00:05:40 +00:00
{{ end }}
<script type="text/javascript">
{{ with $.Scratch.Get "hl_languages" }}
hljs.configure({languages: [{{(delimit . ", ")}}]});
{{ end }}
hljs.initHighlightingOnLoad();
</script>
{{ $.Scratch.Delete "hl_languages" }}
{{ end }}
{{- end -}}