diff options
author | Emir Ribić <ribice@gmail.com> | 2022-04-16 00:08:41 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-16 00:08:41 +0300 |
commit | 35dce884ad0cda3dc47aa5e2c4f5377ac3e3451c (patch) | |
tree | f72f5be9ccf859ef211697c72e3b802f3537220d | |
parent | 5bf5dd7112b3201cf45ff6cfad706395363a7d8e (diff) | |
parent | 403dab7c53a8cd7fb0ce1a5d71c9165452592030 (diff) |
Merge pull request #111 from 6cdh/master
Added math equations and google fonts support
-rw-r--r-- | README.md | 3 | ||||
-rw-r--r-- | exampleSite/config.toml | 3 | ||||
-rw-r--r-- | layouts/partials/gfonts.html | 10 | ||||
-rw-r--r-- | layouts/partials/header.html | 8 | ||||
-rw-r--r-- | layouts/partials/math.html | 46 |
5 files changed, 69 insertions, 1 deletions
@@ -45,6 +45,7 @@ authorEmail = "ribice@gmail.com" # Author email [params.assets] customCSS = ["css/custom.css"] +googleFonts = [] [params.info] adsense = "" # Adsense ID (ID only, without ca-pub-) @@ -57,6 +58,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 5e01845..202a935 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -15,6 +15,7 @@ authorEmail = "ribice@gmail.com" # Author email [params.assets] customCSS = ["css/custom.css"] +googleFonts = [] [params.info] adsense = "" # Adsense ID (ID only, without ca-pub-) @@ -27,6 +28,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/layouts/partials/gfonts.html b/layouts/partials/gfonts.html new file mode 100644 index 0000000..c86e33f --- /dev/null +++ b/layouts/partials/gfonts.html @@ -0,0 +1,10 @@ +<link rel="preconnect" href="https://fonts.gstatic.com" /> +<link + href="https://fonts.googleapis.com/css2?family= +{{- range $index, $font := .Site.Params.Assets.googleFonts -}} + {{- if $index -}}&family={{- end -}} + {{ $font }} +{{- end -}} +&display=swap" + rel="stylesheet" +/> diff --git a/layouts/partials/header.html b/layouts/partials/header.html index f4861b1..5d6277b 100644 --- a/layouts/partials/header.html +++ b/layouts/partials/header.html @@ -18,6 +18,12 @@ {{- 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 }} +{{ if .Site.Params.Assets.googleFonts }} +{{- partial "gfonts" . -}} +{{ 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 +33,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 }} |