提交 d6538441 编写于 作者: EvanOne(文一)'s avatar EvanOne(文一)

docs: Update docs

上级 8f8cac20
......@@ -56,6 +56,12 @@ $ npm install --save-dev hexo-render-pug hexo-renderer-stylus
theme: stun
```
然后,启动 hexo 服务器即可。
``` bash
$ hexo clean && hexo s
```
## 更新
``` bash
......@@ -64,13 +70,13 @@ $ cd themes/stun
$ git pull
```
## 配置
## 文档
请查看:[https://liuyib.github.io/hexo-theme-stun/zh-CN/](https://liuyib.github.io/hexo-theme-stun/zh-CN/)
## 问题
如果使用时出现问题,首先请仔细阅读[文档](https://liuyib.github.io/hexo-theme-stun/zh-CN/),或者查看[常见问题](https://github.com/liuyib/hexo-theme-stun/blob/master/FAQ.md)。当以上的方法都无法解决你的问题时,再去提 `issue`
如果使用时出现问题,首先请仔细阅读[文档](https://liuyib.github.io/hexo-theme-stun/zh-CN/),或者查看[常见问题](https://github.com/liuyib/hexo-theme-stun/blob/master/FAQ.md)。当以上的方法都无法解决你的问题时,再去提 `issue` :hugs:
## 浏览器支持
......@@ -78,4 +84,4 @@ $ git pull
## 开源协议
[MIT](https://github.com/liuyib/hexo-theme-stun/blob/master/LICENSE)
[MIT](https://github.com/liuyib/hexo-theme-stun/blob/master/LICENSE) Copyright (c) 2019 liuyib
......@@ -30,7 +30,7 @@ If you are using the stun theme and would like it to be shown here, you can fill
## Installation
- Install stun
- Install `stun`
Enter your hexo directory, run this.
......@@ -48,12 +48,18 @@ $ npm install --save-dev hexo-render-pug hexo-renderer-stylus
## How to use
Modify the `_config.yml` file in your hexo root directory.
Change the `_config.yml` file in your hexo root directory.
``` yml
theme: stun
```
Run your hexo server.
``` bash
$ hexo clean && hexo s
```
## Update
``` bash
......@@ -62,13 +68,13 @@ $ cd themes/stun
$ git pull
```
## Configuration
## Documentation
Please see: [https://liuyib.github.io/hexo-theme-stun/](https://liuyib.github.io/hexo-theme-stun/)
## Question
If you have problems with your use, please read [documentation](https://liuyib.github.io/hexo-theme-stun/zh-CN/) firstly, or check [FAQ](https://github.com/liuyib/hexo-theme-stun/blob/master/FAQ.md). When the above methods can't solve your problem, then mention `issue`.
If you have problems with your use, please read [documentation](https://liuyib.github.io/hexo-theme-stun/zh-CN/) firstly, or check [FAQ](https://github.com/liuyib/hexo-theme-stun/blob/master/FAQ.md). When the above methods can't solve your problem, then mention `issue` :hugs:.
## Browser Support
......@@ -76,4 +82,4 @@ IE not supported.
## License
[MIT](https://github.com/liuyib/hexo-theme-stun/blob/master/LICENSE)
[MIT](https://github.com/liuyib/hexo-theme-stun/blob/master/LICENSE) Copyright (c) 2019 liuyib
......@@ -2,7 +2,7 @@
## Installation
- Install stun
- Install `stun`
Enter your hexo directory, run this.
......@@ -10,9 +10,9 @@ Enter your hexo directory, run this.
$ git clone https://github.com/liuyib/hexo-theme-stun.git themes/stun
```
- Install pug and stylus
- Install `pug` and `stylus`
If you don't have pug and stylus renderer, run this (If you`re not sure, just do it).
The theme depends on `pug` and `stylus`, please run this.
``` bash
$ npm install --save-dev hexo-render-pug hexo-renderer-stylus
......@@ -20,15 +20,19 @@ $ npm install --save-dev hexo-render-pug hexo-renderer-stylus
## How to use
Modify the `_config.yml` file in your hexo root directory.
Change the `_config.yml` file in your hexo root directory.
``` yml
theme: stun
```
## Update
Run your hexo server.
Enter your hexo directory, run this.
``` bash
$ hexo clean && hexo s
```
## Update
``` bash
$ cd themes/stun
......
......@@ -15,7 +15,7 @@
## 保留主题配置数据
如果你不想每次升级主题时,都要进行如下重复的操作:先将主题配置文件复制一份,等主题升级后再复制回去。那么你可以进行以下操作:将主题配置文件复制到 **Hexo 根目录**下的 `source/_data/stun.yml` 文件中(没有此目录和文件就新建。目录名称不能改变,文件名称可以是任意的)。
如果你不想每次升级主题时,都要进行如下重复的操作:先将主题配置文件复制一份,等主题升级后再复制回去。那么你可以进行以下操作:将主题配置文件复制到 Hexo 根目录下的 `source/_data/stun.yml` 文件中(没有此目录和文件就新建。目录名称不能改变,文件名称可以是任意的)。
> 如果你进行了上述操作,当你需要修改主题配置时,只需要修改 `stun.yml` 文件即可。更新主题时,主题根目录下的 `_config.yml` 文件(可能)会更新,而你对主题配置的数据仍保留在 `stun.yml` 文件中。
......@@ -25,7 +25,7 @@
## 国际化(i18n)
修改 **Hexo 根目录**下的配置文件(不是主题配置文件)`_config.yml`
修改站点配置文件(不是主题配置文件)`_config.yml`
``` yaml
language: zh-CN # 可选值 zh-CN 或 en-US
......@@ -39,7 +39,7 @@ language: zh-CN # 可选值 zh-CN 或 en-US
- 添加路径
修改你的主题配置文件:
修改主题配置文件:
``` yaml
menu:
......@@ -52,7 +52,7 @@ menu:
- 添加图标
修改你的主题配置文件:
修改主题配置文件:
``` yaml
menu:
......@@ -79,7 +79,7 @@ menu_settings:
- 新建页面
**Hexo 根目录**下执行命令:
Hexo 根目录下执行命令:
``` bash
$ hexo new page xxx # xxx 表示页面名称
......@@ -131,7 +131,7 @@ nav:
## Favicon <Badge text="stable"/>
设置网站图标(favicon),修改你的主题配置文件:
设置网站图标(favicon),修改主题配置文件:
``` yaml
favicon:
......@@ -145,7 +145,7 @@ favicon:
## 网站顶部栏信息 <Badge text="stable"/>
修改你的主题配置文件:
修改主题配置文件:
``` yaml
header:
......@@ -172,7 +172,7 @@ header:
## 指定顶部图 <Badge text="stable"/>
如果想要为某个页面或某篇文章单独指定顶部图,你只需要在页面或文章 markdown 源文件的 [front-matter](https://hexo.io/zh-cn/docs/front-matter) 中,添加 `top_image` 项,然后填入的图片 url 或路径即可。例如:
如果想要为某个页面或某篇文章单独指定顶部图,你只需要在页面或文章 markdown 源文件的 [Front-matter](https://hexo.io/zh-cn/docs/front-matter) 中,添加 `top_image` 项,然后填入的图片 url 或路径即可。例如:
``` yaml
......@@ -185,7 +185,7 @@ top_image: https://xxxxx.jpg
## 知识共享许可协议(cc) <Badge text="stable"/>
修改你的主题配置文件:
修改主题配置文件:
``` yaml
creative_commons:
......@@ -208,7 +208,7 @@ creative_commons:
## 返回顶部 <Badge text="beta" type="warn"/>
修改你的主题配置文件:
修改主题配置文件:
``` yaml
back2top:
......@@ -229,7 +229,7 @@ back2top:
## 网站底部栏信息 <Badge text="stable"/>
修改你的主题配置文件:
修改主题配置文件:
``` yaml
footer:
......@@ -292,7 +292,7 @@ footer:
## 侧边栏设置 <Badge text="beta" type="warn"/>
修改你的主题配置文件:
修改主题配置文件:
``` yaml
sidebar:
......@@ -310,7 +310,7 @@ sidebar:
## 侧边栏作者信息 <Badge text="stable"/>
修改你的主题配置文件:
修改主题配置文件:
``` yaml
author:
......@@ -332,7 +332,9 @@ author:
## 社交链接 <Badge text="stable"/>
修改你的主题配置文件:
修改主题配置文件:
> 不想启用的社交链接,直接注释掉就行了。
``` yaml
# `||` 分隔符前面表示社交链接的链接或信息,后面表示社交链接图标。
......@@ -365,7 +367,7 @@ social_setting:
text_align: center
```
当你添加一个主题配置文件里,默认没有的社交链接时,你需要进行国际化设置。这里以添加社交链接 `掘金` 为例,步骤如下:
当你添加一个默认没有的社交链接时,你需要进行国际化设置。这里以添加链接 `掘金` 为例,步骤如下:
1. 修改主题配置文件
......@@ -374,6 +376,8 @@ social:
juejin: https://juejin.im/timeline || origin:掘
```
> 由于 fontawesome 中找不到掘金的 logo,所以这里使用 `掘` 字来代替显示。
2. 修改 `themes/stun/languages` 目录下的文件
`zh-CN`:
......@@ -396,7 +400,7 @@ social:
## 文章目录 <Badge text="stable"/>
修改你的主题配置文件:
修改主题配置文件:
``` yaml
toc:
......@@ -409,7 +413,7 @@ toc:
# 是否始终展开所有文章目录。true:始终展开,false:当文章中对应的标题到达顶部时自动展开。
expand_all: false
# 生成目录时,解析 h 标签的最大深度。
# 你可以在文章的 markdown 源文件的 front-matter 中,通过添加 `toc_max_depth` 字段,
# 你可以在文章的 markdown 源文件的 Front-matter 中,通过添加 `toc_max_depth` 字段,
# 来指定某篇文章生成目录时,解析 h 标签的最大深度。
max_depth: 6
```
......@@ -418,7 +422,7 @@ toc:
## 订阅设置 <Badge text="stable"/>
设置邮件订阅和 RSS 订阅,修改你的主题配置文件:
设置邮件订阅和 RSS 订阅,修改主题配置文件:
``` yaml
feed:
......@@ -430,7 +434,7 @@ feed:
rss:
```
开启 RSS 订阅之前,你需要安装 hexo 插件:[hexo-generator-feed](https://github.com/hexojs/hexo-generator-feed)。然后在 **Hexo 根目录**下的配置文件 `_config.yml` 中添加配置项(关于各个配置项的具体含义,请自行查看插件的文档):
开启 RSS 订阅之前,你需要安装 hexo 插件:[hexo-generator-feed](https://github.com/hexojs/hexo-generator-feed)。然后在站点配置文件 `_config.yml` 中添加配置项(关于各个配置项的具体含义,请自行查看插件的文档):
``` yaml
feed:
......@@ -446,11 +450,11 @@ feed:
icon: icon.png
```
配置完成之后,访问你设置的订阅地址即可看到 RSS 订阅信息。
配置完成之后,访问你设置的订阅地址,如:`https://yoursite.com/atom.xml`,即可看到 RSS 订阅信息。
## 文章阅读进度条 <Badge text="stable"/>
修改你的主题配置文件:
修改主题配置文件:
``` yaml
reading_progress:
......@@ -462,15 +466,13 @@ reading_progress:
height: 1px
```
默认启用。
侧边栏所有效果如下:
![](https://raw.githubusercontent.com/liuyib/picBed/master/hexo-theme-stun/doc/20190619211446.png)
## 文章顶部信息 <Badge text="stable"/>
修改你的主题配置文件:
修改主题配置文件:
``` yaml
post_meta:
......@@ -520,7 +522,7 @@ post_meta:
该功能从 `v1.0.1` 版本开始支持,在 `v1.0.3` 版本中对配置项进行了更改。
:::
如果你想设置首页 或 归档页的文章列表是否分页,可以修改你的主题配置文件:
如果你想设置首页 或 归档页的文章列表是否分页,可以修改主题配置文件:
``` yaml
post_list:
......@@ -532,23 +534,27 @@ post_list:
archives: false
```
默认网站首页的文章列表开启分页,归档页面的文章列表不开启分页。
分页效果如下:
![](https://raw.githubusercontent.com/liuyib/picBed/master/hexo-theme-stun/doc/20190713173927.png)
## 文章列表封面图片 <Badge text="stable"/> <Badge text="v1.0.3"/>
## 文章列表封面图片 <Badge text="stable"/> <Badge text="v1.1.2"/>
如果你为一篇文章单独设置了顶部图,并且想要在文章列表中作为封面图片显示,可以修改你的主题配置文件:
::: tip
该功能从 `v1.0.3` 版本开始支持,在 `v1.1.2` 版本中对配置项进行了更改。
:::
如果你为一篇文章单独设置了顶部图,并且想使用这个顶部图作为文章列表的封面图片来显示,可以修改主题配置文件:
``` yaml
post_list:
# 文章列表里的文章的封面图片
top_image:
cover_image:
home: false
```
默认网站首页的文章列表开启分页,归档页面的文章列表不开启分页。
封面图片效果如下:
![](https://raw.githubusercontent.com/liuyib/picBed/master/hexo-theme-stun/doc/20190713173929.jpg)
......@@ -559,7 +565,7 @@ post_list:
该功能从 `v1.0.0-beta.0` 版本开始支持,在 `v1.0.3` 版本中对配置项进行了更改。
:::
在文章末尾显示文章的所有标签,修改你的主题配置文件:
在文章末尾显示文章的所有标签,修改主题配置文件:
``` yaml
post_widget:
......@@ -577,7 +583,7 @@ post_widget:
该功能从 `v1.0.0-beta.1` 版本开始支持,在 `v1.0.3` 版本中对配置项进行了更改。
:::
在文章末尾自动添加文章结束的提示信息,修改你的主题配置文件:
在文章末尾自动添加文章结束的提示信息,修改主题配置文件:
``` yaml
post_widget:
......@@ -597,7 +603,7 @@ post_widget:
如果想要保留文章摘要,需要**手动**在文章的 markdown 源文件中添加 `<!-- more -->` 标记。标记之前的部分都会被保留为文章摘要,显示在文章列表中。
如果想要自动保留文章摘要,可以通过修改你的主题配置文件:
如果想要自动保留文章摘要,可以通过修改主题配置文件:
``` yaml
auto_excerpt:
......@@ -618,7 +624,7 @@ $ npm uninstall hexo-generator-index --save
$ npm install hexo-generator-index-pin-top --save
```
最后,在文章的 `front-matter` 中,使用 `top: true` 来实现置顶。
最后,在文章的 `Front-matter` 中,使用 `top: true` 来实现置顶。
设置文章置顶后,在文章列表中,可以看到表示置顶的图标。你可以对图标进行设置,修改 `stum.yml` 文件:
......@@ -641,7 +647,7 @@ stick_top:
## 代码高亮 <Badge text="stable"/>
设置代码高亮以及高亮样式,修改你的主题配置文件:
设置代码高亮以及高亮样式,修改主题配置文件:
``` yaml
highlight_theme: light
......@@ -661,29 +667,27 @@ highlight_theme: light
![](https://raw.githubusercontent.com/liuyib/picBed/master/hexo-theme-stun/doc/20190608175154.png)
## 代码换行 <Badge text="stable"/>
## 代码溢出换行 <Badge text="stable"/>
设置代码溢出时,是否换行,修改你的主题配置文件:
修改主题配置文件:
``` yaml
code_word_wrap: true
code_word_wrap: false
```
默认换行。如果设为不换行,当代码溢出时,显示水平滚动条。
效果分别如下:
默认溢出不换行。效果分别如下:
- `code_word_wrap: true`
- 代码溢出换行
![](https://raw.githubusercontent.com/liuyib/picBed/master/hexo-theme-stun/doc/20190608214540.png)
- `code_word_wrap: false`
- 代码溢出不换行
![](https://raw.githubusercontent.com/liuyib/picBed/master/hexo-theme-stun/doc/20190608214539.png)
## 图片水平对齐方式 <Badge text="beta" type="warn"/>
设置文章中图片的水平对齐方式,修改你的主题配置文件:
设置文章中图片的水平对齐方式,修改主题配置文件:
``` yaml
img_horizonal_align:
......@@ -713,7 +717,7 @@ img_horizonal_align:
## 文字与图片的垂直对齐方式 <Badge text="beta" type="warn"/>
如果你没有手动设置**图片的水平对齐方式**(手动设置了请忽略此配置项),那么图片将支持和文字在同一行内显示。此时,如果你想设置文字与图片的垂直对齐方式,修改你的主题配置文件:
如果你没有手动设置**图片的水平对齐方式**(手动设置了请忽略此配置项),那么图片将支持和文字在同一行内显示。此时,如果你想设置文字与图片的垂直对齐方式,修改主题配置文件:
``` yaml
text_vertical_align_with_img: bottom
......@@ -737,7 +741,7 @@ text_vertical_align_with_img: bottom
## 赞赏码 <Badge text="stable"/>
设置文章的赞赏码,修改你的主题配置文件:
设置文章的赞赏码,修改主题配置文件:
``` yaml
# Reward
......@@ -750,13 +754,13 @@ reward:
wechat: https://xxxxx.png
```
默认不启用,启用后效果如下:
效果如下:
![](https://raw.githubusercontent.com/liuyib/picBed/master/hexo-theme-stun/doc/20190608175556.png)
## 标签云 <Badge text="beta" type="warn"/>
如果你启用了 `tags` 页面,想要对其进行设置,修改你的主题配置文件:
如果你启用了 `tags` 页面,想要对其进行设置,修改主题配置文件:
``` yaml
tag_cloud:
......@@ -790,29 +794,30 @@ tag_cloud:
当然,你也可以进行模块化分类:在该目录下新建样式文件,然后通过 `@import xxx` 语句在同目录下的 `index.styl` 文件中引入你新建的样式文件即可。
### 添加 Emoji 支持
## 总结 Front-matter
如果想要使用 Emoji,你可以直接在[这里](http://emojihomepage.com/)复制粘贴使用。如果你更喜欢使用 Emoji 代码,例如:`:sparkles:` 将会显示为 :sparkles:, 那么你需要安装插件 [hexo-filter-github-emojis](https://github.com/crimx/hexo-filter-github-emojis) 来支持这种语法
这里总结一下,Stun 主题中,特有的几种 `Front-matter`
安装这个插件,请在 hexo 根目录下,执行指令:
- `top_image: https://xxxx.jpg`
``` bash
$ npm install hexo-filter-github-emojis --save
```
用于设置文章顶部的大图。详情:[指定顶部图](http://localhost:8080/hexo-theme-stun/zh-CN/advanced/theme-config.html#指定顶部图)
如果你不喜欢 `::` 的语法,你可以使用下面这种方法代替:
- `toc_max_depth: 6`
``` text
{% github_emoji sparkles %}
```
用于设置文章中,解析标题生成目录的最大深度。取值 `1 ~ 6`。例如:`toc_max_depth: 3`,只会解析文中的 `h1`, `h2`, `h3` 来生成目录。详情:[文章目录](http://localhost:8080/hexo-theme-stun/zh-CN/advanced/theme-config.html#文章目录)
如果你需要某个 markdown 文件不解析这种语法,可以在 markdown 文件里的 `front-matter` 中,设置 `no-emoji: true`。这样 `::` 会保持原来的样子。
- `math: true`
是否需要解析数学公式。详情:[数学公式](http://localhost:8080/hexo-theme-stun/zh-CN/advanced/third-part.html#数学公式)
``` yaml
---
title: Hello World
no-emoji: true
---
```
有关该插件的更详尽的用法,请自行查阅其[文档](https://github.com/crimx/hexo-filter-github-emojis)。查看所有支持的 Emoji 请访问:[Github Emojis API](https://api.github.com/emojis) 或者 [Emoji Cheat Sheet](http://www.webpagefx.com/tools/emoji-cheat-sheet/)。
下面是安装某些插件后,可以设置的 `Front-matter`。
- `top: true`
文章是否置顶。详情:[文章置顶](http://localhost:8080/hexo-theme-stun/zh-CN/advanced/theme-config.html#文章置顶)
- `no-emoji: true`
是否解析文章中的 emoji 代码。详情:[添加-emoji-支持](http://localhost:8080/hexo-theme-stun/zh-CN/advanced/third-part.html#%E6%B7%BB%E5%8A%A0-emoji-%E6%94%AF%E6%8C%81)
......@@ -4,6 +4,33 @@
第三方支持正在不断加入中 (๑•̀ㅂ•́)و✧
:::
## 添加 Emoji 支持
如果想要使用 Emoji,你可以直接在[这里](http://emojihomepage.com/)复制粘贴使用。如果你更喜欢使用 Emoji 代码,例如:`:sparkles:` 将会显示为 :sparkles:, 那么你需要安装插件 [hexo-filter-github-emojis](https://github.com/crimx/hexo-filter-github-emojis) 来支持这种语法。
安装这个插件,请在 hexo 根目录下,执行指令:
``` bash
$ npm install hexo-filter-github-emojis --save
```
如果你不喜欢 `::` 的语法,你可以使用下面这种方法代替:
``` text
{% github_emoji sparkles %}
```
如果你需要某个 markdown 文件不解析这种语法,可以在 markdown 文件里的 `front-matter` 中,设置 `no-emoji: true`。这样 `::` 会保持原来的样子。
``` yaml
---
title: Hello World
no-emoji: true
---
```
有关该插件的更详尽的用法,请自行查阅其[文档](https://github.com/crimx/hexo-filter-github-emojis)。查看所有支持的 Emoji 请访问:[Github Emojis API](https://api.github.com/emojis) 或者 [Emoji Cheat Sheet](http://www.webpagefx.com/tools/emoji-cheat-sheet/)。
## 评论系统
### Gitment <Badge text="stable"/>
......@@ -164,7 +191,7 @@ busuanzi:
icon: eye
```
## 搜索支持
## 搜索系统
### Algolia 搜索 <Badge text="stable"/> <Badge text="v1.0.3"/>
......@@ -249,3 +276,161 @@ algolia_search:
```
到这里,不出意外的话,你就可以使用 Algolia 搜索网站里的文章标题了。
## 数学公式
想要解析页面中的数学公式,首先,你需要修改主题配置文件,启用该功能,并选择解析引擎(默认是 mathjax 引擎)。
``` yaml
math:
# 是否启用
enable: true
# 如果设为 true,将会为每一个页面启用该功能
# 如果设为 false,只有在 `Front-matter` 中设置了 `math: true` 的页面,才会启用该功能
per_page: false
# 解析引擎,可选值:mathjax 或 katex(全小写)
engine: mathjax
```
然后,你需要根据下面 MathJax 或 KaTex 的说明进一步配置。
::: tip
MathJax 与 KaTex 相比之下,[KaTex 引擎速度更快](https://www.intmath.com/cg5/katex-mathjax-comparison.php),但 [KaTex 支持的语法更少](https://github.com/KaTeX/KaTeX/wiki/Things-that-KaTeX-does-not-%28yet%29-support),这里是 [KaTex 所支持的所有语法](https://katex.org/docs/supported.html)。
:::
### MathJax <Badge text="stable"/> <Badge text="v1.1.2"/>
使用 mathjax 作为引擎,首先,你需要更换一个支持 MathJax 的 markdown 渲染器:
- [hexo-renderer-kramed](https://github.com/sun11/hexo-renderer-kramed)
- [hexo-renderer-pandoc](https://github.com/wzpan/hexo-renderer-pandoc)
两者选择其一即可。
1. 安装,执行指令。
``` bash
# 卸载原来的渲染器
$ npm un hexo-renderer-marked --save
# 安装新的渲染器
$ npm i hexo-renderer-kramed --save # 或 npm i hexo-renderer-pandoc --save
```
2. 在主题配置文件中,选择 mathjax 引擎。
``` yaml
math:
...
# 全小写
engine: mathjax
```
3. 重启 hexo 服务器。
``` bash
$ hexo clean && hexo s
```
### KaTex <Badge text="stable"/> <Badge text="v1.1.2"/>
使用 katex 作为引擎,不需要引入 `katex.min.js`。相应的,你只需要更换一个支持 KaTex 的 markdown 渲染器。
首先,卸载原来的 markdown 渲染器,例如:
``` bash
npm un hexo-renderer-marked --save
# 或
npm un hexo-renderer-kramed --save
# 或
npm un hexo-renderer-pandoc --save
# 以及
npm un hexo-math --save
```
如果你安装过这些,都需要卸载。你可以到 hexo 根目录下的 `package.json` 文件中,查看安装了哪些插件。然后,安装新的 markdown 渲染器:
- [hexo-renderer-markdown-it-plus](https://github.com/CHENXCHEN/hexo-renderer-markdown-it-plus)
- [hexo-renderer-markdown-it](https://github.com/hexojs/hexo-renderer-markdown-it)
两者选择其一即可。
- 如果你选择 `hexo-renderer-markdown-it-plus` 作为渲染器。
1. 安装,执行指令。
``` bash
$ npm i hexo-renderer-markdown-it-plus --save
```
2. 在主题配置文件中,选择 katex 引擎。
``` yaml
math:
...
engine: katex
```
3. 重启 hexo 服务器。
``` bash
$ hexo clean && hexo s
```
- 如果你选择 `hexo-renderer-markdown-it` 作为渲染器。
你需要额外安装 `markdown-it-katex`。
1. 安装,执行指令。
``` bash
$ npm i hexo-renderer-markdown-it --save
$ npm i markdown-it-katex --save
```
2. 修改站点配置文件
添加 或 修改 `hexo-renderer-markdown-it` 的配置项。
``` yaml
markdown:
render:
html: true
xhtmlOut: false
breaks: true
linkify: true
typographer: true
quotes: '“”‘’'
plugins:
- markdown-it-katex
```
有关 `hexo-renderer-markdown-it` 所有的配置项,在[这里](https://github.com/hexojs/hexo-renderer-markdown-it/wiki/Advanced-Configuration#all-options-configuration)查看。
3. 选择 katex 引擎 和 重启 hexo 服务器的步骤同上。
### 插件
Stun 主题默认提供了一些 MathJax 和 Katex 的插件。
- mhchem
mhchem 是 MathJax 的插件,你可以使用这个插件来渲染化学方程式。详情请看:[MathJax/mhchem Manual](https://mhchem.github.io/MathJax-mhchem/)。
- Copy-tex
Copy-tex 是 KaTex 的插件,当启用这个插件之后,你只需要单击公式即可复制其源码。详情请看:[Copy-tex extension](https://github.com/KaTeX/KaTeX/tree/master/contrib/copy-tex)。
效果如下:
![](https://raw.githubusercontent.com/liuyib/picBed/master/hexo-theme-stun/doc/20190720153859.gif)
### 使用
按照上述步骤配置之后,你就可以在 markdown 源文件中,使用数学公式了。使用 `$$...$$` 包裹的字符,即可被识别为数学公式,但是会另起一行来显示。如果想要公式和文字在同一行显示,需要使用 `$...$` 来包括字符。
效果如下:
![](https://raw.githubusercontent.com/liuyib/picBed/master/hexo-theme-stun/doc/20190720160555.png)
......@@ -12,7 +12,7 @@ $ git clone https://github.com/liuyib/hexo-theme-stun.git themes/stun
- 安装 pug 和 stylus
如果你没有安装对 pug、stylus 的支持,请执行指令(如果你不确定,直接执行指令就好了)
主题依赖于 pug 和 stylus,请执行指令
``` bash
$ npm install --save-dev hexo-render-pug hexo-renderer-stylus
......@@ -20,15 +20,19 @@ $ npm install --save-dev hexo-render-pug hexo-renderer-stylus
## 使用
修改 hexo 根目录下的 _config.yml 文件。
修改 hexo 根目录下的 `_config.yml` 文件。
``` yaml
``` yml
theme: stun
```
## 更新
然后,启动 hexo 服务器即可。
进入 Hexo 根目录,执行指令。
``` bash
$ hexo clean && hexo s
```
## 更新
``` bash
$ cd themes/stun
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册