Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ertuil/erblog.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLutong Chen <ertuil98@foxmail.com>2020-05-28 04:13:23 +0300
committerLutong Chen <ertuil98@foxmail.com>2020-05-28 04:13:55 +0300
commit15133cfc83cd3a78528f73e79bc40d16d4b11e5d (patch)
tree5103af54e6ce5fde506836d5a062cf3f9f5f8afa
parent2edcda21a573b5100001e15dfd138318c58f568b (diff)
Mathjax: Load on demand
-rw-r--r--README.md7
-rw-r--r--exampleSite/content/post/math-typesetting.mmark4
-rw-r--r--layouts/partials/head.html15
3 files changed, 22 insertions, 4 deletions
diff --git a/README.md b/README.md
index a599872..9e5899a 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,11 @@
# Erblog
+> ⚠️⚠️⚠️ **Note:** Mathjax is not included directly due to the performance considerations new!
+>
+> Use `math: true` in Front Matter 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">