Skip to content

Commit

Permalink
Merge branch 'pr/268' into dev-1.6.3
Browse files Browse the repository at this point in the history
  • Loading branch information
LolipopJ committed Jul 18, 2021
2 parents 350e631 + 953319f commit 1e899d0
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 23 deletions.
71 changes: 48 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

### 启动博客预览
Expand Down Expand Up @@ -116,23 +116,48 @@ npm install hexo-filter-mermaid-diagrams --save

``` yml
mermaid:
enable: true
enable: true
```

测试 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)
Expand Down Expand Up @@ -194,6 +219,6 @@ mermaid:
- 2021.01.26 - 『更新使用的 nodejs,以及相关依赖包的版本』
- 2021.02.03 - 『添加“文章时效性”提示』

## 许可证
## License

MIT
4 changes: 4 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
29 changes: 29 additions & 0 deletions layout/mathjax.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<% if (theme.mathjax.enable){ %>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
tex2jax: {
inlineMath: [ ['$','$'], ["\\(","\\)"] ],
processEscapes: true
}
});
</script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
tex2jax: {
skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
}
});
</script>
<script type="text/x-mathjax-config">
MathJax.Hub.Queue(function() {
var all = MathJax.Hub.getAllJax(), i;
for(i=0; i < all.length; i += 1) {
all[i].SourceElement().parentNode.className += ' has-jax';
}
});
</script>
<script type="text/javascript" src="<%- theme.mathjax.cdn %>"></script>
<% } %>
3 changes: 3 additions & 0 deletions layout/post.ejs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<main class="main post-page">
<% if (page.mathjax == true){ %>
<%- partial('mathjax') %>
<% } %>
<article class="article-entry">
<%- page.content %>
</article>
Expand Down

0 comments on commit 1e899d0

Please sign in to comment.