From cb991e36fd582bb1bcc8ee58621d2feaae409866 Mon Sep 17 00:00:00 2001 From: imzeuk Date: Tue, 16 Apr 2019 15:04:06 +0800 Subject: add MathJax --- README.md | 6 ++++++ exampleSite/config.toml | 8 +++++++- exampleSite/content/posts/theme-preview.md | 28 ++++++++++++++++++++++++- layouts/partials/js.html | 4 ++++ layouts/partials/mathjax.html | 33 ++++++++++++++++++++++++++++++ 5 files changed, 77 insertions(+), 2 deletions(-) create mode 100644 layouts/partials/mathjax.html diff --git a/README.md b/README.md index fe26f51..b55538e 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,12 @@ $ git clone https://github.com/imzeuk/hugo-theme-zozo themes/zozo 关于页面就是这么实现的。 +## Math 公式 + +本主题支持 MathJax 数学公式,默认为关闭状态,如需使用,需要在 [`config.toml`](./exampleSite/config.toml) 中进行设置。 + +设置 `[params]` 下的 `mathjax = true` 来支持数学公式。 + ## Valine 评论 本主题提供了 Valine 评论系统,默认为关闭状态,如需使用,需要在 [`config.toml`](./exampleSite/config.toml) 中进行设置。 diff --git a/exampleSite/config.toml b/exampleSite/config.toml index d94f8ac..779c0e0 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -11,6 +11,9 @@ enableEmoji = true [author] # essential # 必需 name = "Zeuk" +[blackfriday] + smartypants = false + [[menu.main]] # config your menu 配置菜单 name = "首页" weight = 10 @@ -33,11 +36,14 @@ enableEmoji = true url = "/about/" [params] - subTitle = "the site subtitle" # 网站二级标题 + subTitle = "the site subtitle" # 网站二级标题 footerSlogan = "我的精神家园" # 网站页脚标语 keywords = ["Hugo", "theme","zozo"] # 网站关键字 description = "Hugo theme zozo example site." # 网站描述 + # mathjax + mathjax = true # 是否使用mathjax(数学公式) + # Valine. # You can get your appid and appkey from https://leancloud.cn # more info please open https://valine.js.org diff --git a/exampleSite/content/posts/theme-preview.md b/exampleSite/content/posts/theme-preview.md index b5f4fb7..ff75f6e 100644 --- a/exampleSite/content/posts/theme-preview.md +++ b/exampleSite/content/posts/theme-preview.md @@ -141,7 +141,33 @@ function doIt() { - Second item - Third item -# Emoji +# Math + +``` +$$ +evidence\_{i}=\sum\_{j}W\_{ij}x\_{j}+b\_{i} +$$ + +$$ +AveP = \int_0^1 p(r) dr +$$ + +When $a \ne 0$, there are two solutions to \(ax^2 + bx + c = 0\) and they are +$$x = {-b \pm \sqrt{b^2-4ac} \over 2a}.$$ +``` + +$$ +evidence\_{i}=\sum\_{j}W\_{ij}x\_{j}+b\_{i} +$$ + +$$ +AveP = \int_0^1 p(r) dr +$$ + +When $a \ne 0$, there are two solutions to \(ax^2 + bx + c = 0\) and they are +$$x = {-b \pm \sqrt{b^2-4ac} \over 2a}.$$ + +#### Emoji This is a test for emoji. :smile: diff --git a/layouts/partials/js.html b/layouts/partials/js.html index 46225b5..283efdb 100644 --- a/layouts/partials/js.html +++ b/layouts/partials/js.html @@ -5,3 +5,7 @@ + +{{ if .Site.Params.mathjax }} + {{ partial "mathjax.html" . }} +{{ end }} diff --git a/layouts/partials/mathjax.html b/layouts/partials/mathjax.html new file mode 100644 index 0000000..a8c59ab --- /dev/null +++ b/layouts/partials/mathjax.html @@ -0,0 +1,33 @@ + + + \ No newline at end of file -- cgit v1.2.3