diff --git a/README.md b/README.md index 8d4e4f42..af4d42e0 100644 --- a/README.md +++ b/README.md @@ -52,23 +52,23 @@ theme: archer ``` yaml jsonContent: - meta: true - pages: false - posts: - title: true - date: true - path: true - text: false - raw: false - content: false - slug: false - updated: false - comments: false - link: false - permalink: true - excerpt: false - categories: true - tags: true + meta: true + pages: false + posts: + title: true + date: true + path: true + text: false + raw: false + content: false + slug: false + updated: false + comments: false + link: false + permalink: true + excerpt: false + categories: true + tags: true ``` ### 启动博客预览 @@ -116,7 +116,7 @@ npm install hexo-filter-mermaid-diagrams --save ``` yml mermaid: - enable: true + enable: true ``` 测试 Mermaid 是否启用成功,您可以在任意文章中添加下面的内容(您需要取消缩进): @@ -124,15 +124,40 @@ mermaid: ``` markdown ``` mermaid graph TD; - A-->B; - A-->C; - B-->D; - C-->D; + A-->B; + A-->C; + B-->D; + C-->D; ``` ``` > ❗️❗️❗️ 注意:如果您需要使用**类图**,请编辑您 Hexo 根目录下的 `_config.yml` 文件,设置 `external_link: false`。请确保这个设置对您原来的博客功能没有影响,这是 Hexo 本身的 bug。 +## 启用 LaTeX + +Archer 主题已经内置了 MathJax,但是您需要替换 Hexo 默认的渲染引擎来支持解析 LaTeX 语法。 + +在 Hexo 根目录下执行下面的命令: + +``` bash +npm uninstall hexo-renderer-marked --save +npm install hexo-renderer-kramed --save +``` + +对需要启用 LaTeX 的文章的 Front-matter 中添加 `mathjax: true` 字段。测试 LaTeX 是否启用成功,您可以在这篇文章中添加下面的内容: + +``` markdown +\begin{equation} +\left\{ +\begin{array}{lr} +x=\dfrac{3\pi}{2}(1+2t)\cos(\dfrac{3\pi}{2}(1+2t)), & \\ +y=s, & 0 \leq s \leq L,|t| \leq1. \\ +z=\dfrac{3\pi}{2}(1+2t)\sin(\dfrac{3\pi}{2}(1+2t)), & +\end{array} +\right. +\end{equation} +``` + ### 其它可选配置 - [启用 about 页](https://github.com/fi3ework/hexo-theme-archer/wiki/%E5%90%AF%E7%94%A8about%E9%A1%B5) @@ -194,6 +219,6 @@ mermaid: - 2021.01.26 - 『更新使用的 nodejs,以及相关依赖包的版本』 - 2021.02.03 - 『添加“文章时效性”提示』 -## 许可证 +## License MIT diff --git a/_config.yml b/_config.yml index e6abfc9d..85380671 100644 --- a/_config.yml +++ b/_config.yml @@ -154,3 +154,7 @@ mermaid: version: 8.11.0 theme: dark options: # find more api options from https://github.com/knsv/mermaid/blob/master/src/mermaidAPI.js +# MathJax Support +mathjax: + enable: true + cdn: https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.6/MathJax.js?config=TeX-AMS-MML_HTMLorMML \ No newline at end of file diff --git a/layout/mathjax.ejs b/layout/mathjax.ejs new file mode 100644 index 00000000..31e6267f --- /dev/null +++ b/layout/mathjax.ejs @@ -0,0 +1,29 @@ +<% if (theme.mathjax.enable){ %> + + + + + + + +<% } %> \ No newline at end of file diff --git a/layout/post.ejs b/layout/post.ejs index 5e4e06dd..ffa7e2af 100644 --- a/layout/post.ejs +++ b/layout/post.ejs @@ -1,4 +1,7 @@
+ <% if (page.mathjax == true){ %> + <%- partial('mathjax') %> + <% } %>
<%- page.content %>