diff options
author | 6cdh <cd6cdh@gmail.com> | 2021-02-27 16:21:14 +0300 |
---|---|---|
committer | 6cdh <cd6cdh@gmail.com> | 2021-02-27 16:21:14 +0300 |
commit | 8cbbd911190856c4e6aa8a1d01fac3a4559d7266 (patch) | |
tree | 7fd82b845d64385b55fda18e15338b5825186556 | |
parent | f061118086d776771c6a36d007a1c016966a1c46 (diff) |
Added math equations support
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | exampleSite/config.toml | 4 | ||||
-rw-r--r-- | layouts/partials/header.html | 5 | ||||
-rw-r--r-- | layouts/partials/math.html | 46 |
4 files changed, 55 insertions, 2 deletions
@@ -57,6 +57,8 @@ taxonomiesCount = true # Add taxonomies count [params.features] disqusOnDemand = true # Load Disqus comments on click +mathjax = false +katex = false [params.opengraph.facebook] diff --git a/exampleSite/config.toml b/exampleSite/config.toml index 178b63e..2386433 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -27,6 +27,8 @@ taxonomiesCount = true # Add taxonomies count [params.features] disqusOnDemand = true # Load Disqus comments on click +mathjax = false +katex = false [params.opengraph.facebook] @@ -61,4 +63,4 @@ rootURL = "//fathom.example.com/" tag ="tags" [blackfriday] -hrefTargetBlank = true
\ No newline at end of file +hrefTargetBlank = true diff --git a/layouts/partials/header.html b/layouts/partials/header.html index f4861b1..20e77fc 100644 --- a/layouts/partials/header.html +++ b/layouts/partials/header.html @@ -18,6 +18,9 @@ {{- range .Site.Params.Assets.customCSS -}} <link rel='stylesheet' href='{{ . | absURL }}'> {{- end -}} +{{ if or .Site.Params.Features.mathjax .Params.mathjax .Site.Params.Features.katex .Params.katex }} +{{- partial "math" . -}} +{{ end }} <link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png"> <link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png"> <link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png"> @@ -27,4 +30,4 @@ <meta name="msapplication-TileColor" content="#da532c"> <meta name="theme-color" content="#ffffff"> </head> -<body>
\ No newline at end of file +<body> diff --git a/layouts/partials/math.html b/layouts/partials/math.html new file mode 100644 index 0000000..c60f3a7 --- /dev/null +++ b/layouts/partials/math.html @@ -0,0 +1,46 @@ +{{ if or .Site.Params.Features.mathjax .Params.mathjax }} +<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script> +<script + id="MathJax-script" + async + src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js" +></script> +<script> + MathJax = { + tex: { + inlineMath: [["$", "$"]], + }, + }; +</script> +{{ end }} + +{{ if or .Site.Params.Features.katex .Params.katex }} +<link + rel="stylesheet" + href="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/katex.min.css" + integrity="sha384-AfEj0r4/OFrOo5t7NnNe46zW/tFgW6x/bCJG8FqQCEo3+Aro6EYUG4+cU+KJWu/X" + crossorigin="anonymous" +/> +<script + defer + src="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/katex.min.js" + integrity="sha384-g7c+Jr9ZivxKLnZTDUhnkOnsh30B4H0rpLUpJ4jAIKs4fnJI+sEnkvrMWph2EDg4" + crossorigin="anonymous" +></script> +<script + defer + src="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/contrib/auto-render.min.js" + integrity="sha384-mll67QQFJfxn0IYznZYonOWZ644AWYC+Pt2cHqMaRhXVrursRwvLnLaebdGIlYNa" + crossorigin="anonymous" +></script> +<script> + document.addEventListener("DOMContentLoaded", function() { + renderMathInElement(document.body, { + delimiters: [ + { left: "$$", right: "$$", display: true }, + { left: "$", right: "$", display: false }, + ], + }); + }); +</script> +{{ end }} |