diff options
author | Hang Jiang <jianghangscu@gmail.com> | 2021-08-16 09:24:56 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-16 09:24:56 +0300 |
commit | 49de4bd97832de9999664a546883f73063f6c845 (patch) | |
tree | 11b50b8c3bcbeffc22e3f02c9dbc1c6da51ffb53 | |
parent | 23c428dcfbf7a49c46ca2bd6220198d2d1cbaea5 (diff) | |
parent | ec7b548d1dcc2277cbe016a9725ed96e8fc8eb41 (diff) |
Merge pull request #99 from nodejh/feature/math
support math typesetting
-rw-r--r-- | README-zh_CN.md | 22 | ||||
-rw-r--r-- | README.md | 19 | ||||
-rw-r--r-- | exampleSite/config.yaml | 10 | ||||
-rw-r--r-- | layouts/partials/head.html | 6 | ||||
-rw-r--r-- | layouts/partials/math.html | 5 |
5 files changed, 46 insertions, 16 deletions
diff --git a/README-zh_CN.md b/README-zh_CN.md index 34ff44a..11c74e0 100644 --- a/README-zh_CN.md +++ b/README-zh_CN.md @@ -135,17 +135,17 @@ hugo ## 3. 可选配置 -### 3.1 在某些页面禁用评论 +### 3.1 在某页面禁用评论 -要在某个页面禁用评论,你可以在页面 Front Matter 中指定 `enableComments = false`。 +要在某页面禁用评论,你可以在页面的 Front Matter 中将 `enableComments` 设置为 `false`。 例如: -``` -+++ -title = "Some title" -enableComments = false -+++ +```yaml +--- +title: Some title +enableComments: false +--- ``` ### 3.2 自定义 CSS 和 JS @@ -164,6 +164,14 @@ customJS: ``` +### 3.3 数学排版 + +该主题使用了 [KaTeX](https://katex.org/) 来支持数学符号拍版。 + +- 全局支持数学排版:在项目的配置文件中将 `math` 设置为 `true` +- 在某页面支持数学拍版:在某页面 Front Matter 中将 `math` 设置为 `true` + + ## License [MIT](https://github.com/nodejh/hugo-theme-mini/blob/master/LICENSE.md)
\ No newline at end of file @@ -136,15 +136,15 @@ hugo ### 3.1 Disable Comments on a single post -You can set `enableComments = false` in front matter to disable disqus comments on a single post. +You can set `enableComments` to `false` in front matter to disable disqus comments on a single post. For example: -``` -+++ -title = "Some title" -enableComments = false -+++ +```yaml +--- +title: Some title +enableComments: false +--- ``` ### 3.2 Custom CSS and JS @@ -162,6 +162,13 @@ customJS: - https://example.com/custom.js # remote js ``` +### 3.3 Math Typesetting + +Mathematical notation is enabled by [KaTeX](https://katex.org/). + +- To enable KaTex globally set the parameter `math` to t`rue` in project’s configuration +- To enable KaTex on a per page basis include the parameter `math` to `true` in content files + ## License diff --git a/exampleSite/config.yaml b/exampleSite/config.yaml index 0a7ba90..b3ece8c 100644 --- a/exampleSite/config.yaml +++ b/exampleSite/config.yaml @@ -38,6 +38,12 @@ params: bio: Software Engineer # Site Description, used in HTML meat description: My Blog + + + ########################################### + # Optional + ########################################### + # To enable RSS, you could set `enableRSS: true`, default is `true` enableRSS: true # To enable comments, you may need to set `disqusShortname` @@ -46,8 +52,10 @@ params: enableGoogleAnalytics: true # To hidden powerBy message in the page footer, you could set: `showPowerBy: false`, default is `true` showPowerBy: true + # To enable math typesetting , you could set `math: true` + math: false - # Optional + # text in page home: '' # Default: Home about: '' # Default: About archive: '' # Default: Archive diff --git a/layouts/partials/head.html b/layouts/partials/head.html index 79d9236..43cc32e 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -28,11 +28,13 @@ {{ template "_internal/google_analytics_async.html" . }} {{ end }} +{{ if or .Params.math .Site.Params.math }} + {{ partial "math.html" . }} +{{ end }} {{ if .OutputFormats.Get "RSS" }} {{ with .OutputFormats.Get "RSS" }} <link href="{{ .RelPermalink }}" rel="alternate" type="application/rss+xml" title="{{ $.Site.Title }}" /> <link href="{{ .RelPermalink }}" rel="feed" type="application/rss+xml" title="{{ $.Site.Title }}" /> {{ end }} -{{ end }} - +{{ end }}
\ No newline at end of file diff --git a/layouts/partials/math.html b/layouts/partials/math.html new file mode 100644 index 0000000..7c1279a --- /dev/null +++ b/layouts/partials/math.html @@ -0,0 +1,5 @@ +<!-- https://katex.org/docs/autorender.html --> +<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.13.13/dist/katex.min.css" integrity="sha384-RZU/ijkSsFbcmivfdRBQDtwuwVqK7GMOw6IMvKyeWL2K5UAlyp6WonmB8m7Jd0Hn" crossorigin="anonymous"> +<script defer src="https://cdn.jsdelivr.net/npm/katex@0.13.13/dist/katex.min.js" integrity="sha384-pK1WpvzWVBQiP0/GjnvRxV4mOb0oxFuyRxJlk6vVw146n3egcN5C925NCP7a7BY8" crossorigin="anonymous"></script> +<script defer src="https://cdn.jsdelivr.net/npm/katex@0.13.13/dist/contrib/auto-render.min.js" integrity="sha384-vZTG03m+2yp6N6BNi5iM4rW4oIwk5DfcNdFfxkk9ZWpDriOkXX8voJBFrAO7MpVl" crossorigin="anonymous" + onload="renderMathInElement(document.body);"></script>
\ No newline at end of file |