diff options
author | Lutong Chen <ertuil98@foxmail.com> | 2020-05-28 04:13:23 +0300 |
---|---|---|
committer | Lutong Chen <ertuil98@foxmail.com> | 2020-05-28 04:13:23 +0300 |
commit | 8660f0bdb9090d754cdbeb83a464a888db762002 (patch) | |
tree | 2358c38f41570135a9363484d71c72dd2dab50ed | |
parent | 2edcda21a573b5100001e15dfd138318c58f568b (diff) |
Mathjax: Load on demand
-rw-r--r-- | README.md | 7 | ||||
-rw-r--r-- | exampleSite/content/post/math-typesetting.mmark | 4 | ||||
-rw-r--r-- | layouts/partials/head.html | 15 |
3 files changed, 22 insertions, 4 deletions
@@ -1,5 +1,11 @@ # Erblog +> ⚠️⚠️⚠️ **Note:** Mathjax is not included directly due to the performance considerations new! +> +> Use `math: true` in Front Matter of each post to enable Mathjax in each single page. +> +> Or set `Params.math: true` to enable it globally. + A personal blog theme powered by [Hugo](https://gohugo.io). Erblog is written by Ertuil with [layui.js](https://www.layui.com), [font-awssome](https://fontawesome.com), github markdown css and [undraw](https://undraw.co). @@ -53,6 +59,7 @@ There are some basic configuration options you may want to use: | Params.bio | A Biography for your Blog | None | | Params.logo | Your Blog's Logo | None | | Params.favicon | The favicon file | /favicon.ico | +| Params.math | import mathjax globally | false | | Params.index_posts_num | The number of posts displayed in Index | 5 | | Params.google_search | Enable Google Intra-Site Search Engine | false | | Params.badge | The color for badge ('red', 'cyan', 'orange', 'green', 'blue', 'black' and 'gray' are available) | 'red' | diff --git a/exampleSite/content/post/math-typesetting.mmark b/exampleSite/content/post/math-typesetting.mmark index 7f421ae..1426077 100644 --- a/exampleSite/content/post/math-typesetting.mmark +++ b/exampleSite/content/post/math-typesetting.mmark @@ -3,7 +3,6 @@ author: Hugo Authors title: Math Typesetting date: 2019-03-08 description: A brief guide to setup KaTeX -markup: mmark math: true --- @@ -25,12 +24,15 @@ In this example we will be using [KaTeX](https://katex.org/) - To enable KaTex on a per page basis include the parameter `math: true` in content files. **Note:** Use the online reference of [Supported TeX Functions](https://katex.org/docs/supported.html) + {{< math.inline >}} {{ if or .Page.Params.math .Site.Params.math }} <!-- KaTeX --> +<!-- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.10.1/dist/katex.min.css" integrity="sha384-dbVIfZGuN1Yq7/1Ocstc1lUEm+AT+/rCkibIcC/OmWo5f0EA48Vf8CytHzGrSwbQ" crossorigin="anonymous"> <script defer src="https://cdn.jsdelivr.net/npm/katex@0.10.1/dist/katex.min.js" integrity="sha384-2BKqo+exmr9su6dir+qCw08N2ZKRucY4PrGQPPWU1A7FtlCGjmEGFqXCv5nyM5Ij" crossorigin="anonymous"></script> <script defer src="https://cdn.jsdelivr.net/npm/katex@0.10.1/dist/contrib/auto-render.min.js" integrity="sha384-kWPLUVMOks5AQFrykwIup5lo0m3iMkkHrD0uJ4H5cjeGihAutqP0yW0J6dpFiVkI" crossorigin="anonymous" onload="renderMathInElement(document.body);"></script> +--> {{ end }} {{</ math.inline >}} diff --git a/layouts/partials/head.html b/layouts/partials/head.html index 689beb7..6d1460a 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -31,12 +31,21 @@ </script> {{ end }} - {{ if .Site.Params.MathJax | default true }} + {{ if or .Page.Params.math .Site.Params.math }} <!-- adds MathJax support --> - <script async src="https://cdn.jsdelivr.net/npm/mathjax@3.0.5/es5/tex-mml-chtml.js" integrity="sha256-HGLuEfFcsUJGhvB8cQ8nr0gai9EucOOaIxFw7qxmd+w=" crossorigin="anonymous"></script> <script type="text/x-mathjax-config"> - MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}}); + MathJax.Hub.Config({ + extensions: ["tex2jax.js"], + jax: ["input/TeX", "output/HTML-CSS"], + tex2jax: { + inlineMath: [ ['$','$'], ["\\(","\\)"] ], + displayMath: [ ['$$','$$'], ["\\[","\\]"] ], + processEscapes: true + }, + "HTML-CSS": { availableFonts: ["TeX"] } + }); </script> + <script src="https://cdn.jsdelivr.net/npm/mathjax@3.0.5/es5/tex-mml-chtml.js" integrity="sha256-HGLuEfFcsUJGhvB8cQ8nr0gai9EucOOaIxFw7qxmd+w=" crossorigin="anonymous"></script> {{ end }} <link rel="stylesheet" href="/layui/css/layui.css"> |