caffeinated.blog/themes/anatole/layouts/partials/math.html

45 lines
1.9 KiB
HTML
Raw Normal View History

{{- if or (eq site.Params.math true) (eq .Params.math true) -}}
{{- $use := "katex" -}}
{{- with site.Params.math -}}
{{- if and (isset . "use") (eq (.use | lower) "mathjax") -}}
{{- $use = "mathjax" -}}
{{- end -}}
{{- end -}}
{{- if eq $use "mathjax" -}}
{{- $url := "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/MathJax.js?config=TeX-AMS-MML_HTMLorMML" -}}
{{- $hash := "sha384-e/4/LvThKH1gwzXhdbY2AsjR3rm7LHWyhIG5C0jiRfn8AN2eTN5ILeztWw0H9jmN" -}}
<script defer
type="text/javascript"
src="{{- $url -}}"
integrity="{{- $hash -}}"
crossorigin="anonymous"></script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [['$','$'], ['\\(','\\)']] } });
</script>
{{- else -}}
{{- $url := "https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/katex.min.css" -}}
{{- $hash := "sha384-zB1R0rpPzHqg7Kpt0Aljp8JPLqbXI3bhnPWROx27a9N0Ll6ZP/+DiW/UqRcLbRjq" -}}
<link rel="stylesheet"
href="{{- $url -}}"
integrity="{{- $hash -}}"
crossorigin="anonymous">
{{- $url := "https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/katex.min.js" -}}
{{- $hash := "sha384-y23I5Q6l+B6vatafAwxRu/0oK/79VlbSz7Q9aiSZUvyWYIYsd+qj+o24G5ZU2zJz" -}}
<script defer
src="{{- $url -}}"
integrity="{{- $hash -}}"
crossorigin="anonymous"></script>
{{- $url := "https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/contrib/auto-render.min.js" -}}
{{- $hash := "sha384-kWPLUVMOks5AQFrykwIup5lo0m3iMkkHrD0uJ4H5cjeGihAutqP0yW0J6dpFiVkI" -}}
<script defer
src="{{- $url -}}"
integrity="{{- $hash -}}"
crossorigin="anonymous"
onload="renderMathInElement(document.body);"></script>
{{- end -}}
{{- end -}}