diff --git a/docs/zh-CN/advanced/assist.md b/docs/zh-CN/advanced/assist.md index ea07c2cc977079336a40fa7e6836842cf5bfe8f4..563d2b7f6d7bf9c5e2ddddff4f9f8ed42f380fa5 100644 --- a/docs/zh-CN/advanced/assist.md +++ b/docs/zh-CN/advanced/assist.md @@ -2,7 +2,7 @@ ## 快捷键 -- 快速切换文章 +### 快速切换文章 ::: tip 该功能在 `v1.1.0` 版本中快捷键为(`←`:切换到上一篇文章,`→`:切换到下一篇文章),在 `v1.1.3` 版本中快捷键修改为(Ctrl + `←`,Ctrl + `→`)。 @@ -24,6 +24,65 @@ shortcuts: > 考虑到这里的快捷键可能会和用户系统或软件的冲突,所以在 Stun 主题 `v1.1.3` 版本中,这个功能加入了配置项,用户可以自己决定是否开启,默认不启用。并且在 Stun 主题以后的版本中,可能会留出配置项让用户自定义快捷键。 -- 快速关闭搜索框 +### 快速关闭搜索框 关闭搜索框有三种方式,1. 点击关闭按钮,2. 点击蒙版,3. 按下 `Esc` 键。 + +## 标签插件 + +该功能相当于 Hexo 对 markdown 语法的一种扩展,用于快速在文章中插入指定的内容。你可以访问[这里](https://hexo.io/zh-cn/docs/tag-plugins)查看 Hexo 都支持哪些标签插件。 + +Hexo 主题一般都会扩展一些自己特有的标签插件,在这方面做得最好的是 NexT 主题,你可以查看 NexT 主题所特有的标签插件:[https://theme-next.org/docs/tag-plugins/](https://theme-next.org/docs/tag-plugins/)。 + +此外,Stun 主题也有自己扩展的一些标签插件,这些标签插件如下: + +### 插入表格数据 + +如果想要在文章中显示一个表格,你可以使用 markdown 原生支持的语法,但是如果你想要让表格里的数据存储在外部文件中,那么你可以使用下面这种语法: + +``` +{% table [path], [thead1, thead2, ...] %} +``` + +参数: + +`[path]`:数据文件的路径 + +`[thead1, thead2, ...]`:表格头部的文字(表格有几列就要写几项) + +::: warning +数据文件必须放在 `/source/` 目录下,建议放在 `/source/_data/` 目录下。 +::: + +举例: + +在文章或页面中显示一个打赏列表。 + +1. 在 `/source/_data/` 目录下新建文件 `reward.json`,填入数据。 + +``` json +[ + { + "time": "2019-6-1", + "sponsor": "张三", + "money": "9.9", + "remark": "支持一下~" + }, + { + "time": "2019-6-16", + "sponsor": "李四", + "money": "11", + "remark": "前来支持,继续加油!" + } +] +``` + +2. 在文章或页面的 markdown 源文件中,插入如下标签。 + +``` +{% table _data/reward.json, 时间, 赞助人, 金额, 留言 %} +``` + +3. 重启 Hexo 服务器,效果如下。 + +![](https://raw.githubusercontent.com/liuyib/picBed/master/hexo-theme-stun/doc/20190802171506.png) diff --git a/docs/zh-CN/advanced/theme-config.md b/docs/zh-CN/advanced/theme-config.md index 32f63b7ec65bb505cc883961a79095f5e4f9dc20..5b495b9cf582f115ad486d2f33f80fd5cd198f3e 100644 --- a/docs/zh-CN/advanced/theme-config.md +++ b/docs/zh-CN/advanced/theme-config.md @@ -941,7 +941,7 @@ external_link: color: "#aaa" ``` -## FancyBox +### FancyBox 如果想要使用 fancybox 功能,只需要修改主题配置文件即可: diff --git a/languages/en.yml b/languages/en.yml index bf5e2207bb96dd72dc75162ae5bcb707da2d88a4..b0e0d14127f91717d44ec12d95457d72657bcded 100644 --- a/languages/en.yml +++ b/languages/en.yml @@ -27,7 +27,7 @@ sidebar: overview: Overview catalog: Catalog subscribe: Subscribe - articles: Articles + archives: Archives categories: Categories tags: Tags read_info: You have read @@ -92,6 +92,7 @@ footer: uv: Visitors pv: Views +# Global notification notification: copy: success: Copy Success diff --git a/languages/zh-CN.yml b/languages/zh-CN.yml index e9c21b8a6f9cb92145964d9c048aafde597603e5..596aa1c56d03f1f11e7b6ee9148314ce80e5a464 100644 --- a/languages/zh-CN.yml +++ b/languages/zh-CN.yml @@ -27,7 +27,7 @@ sidebar: overview: 站点概览 catalog: 文章目录 subscribe: 订阅 - articles: 文章 + archives: 归档 categories: 分类 tags: 标签 read_info: 你已阅读了 @@ -92,6 +92,7 @@ footer: uv: 访问人数 pv: 浏览总量 +# 全局消息提示信息 notification: copy: success: 复制成功 diff --git a/layout/_common/sidebar.pug b/layout/_common/sidebar.pug index 645867c3507a7c80c55d698e8f9a4c54baa5f970..7ea6c1a541314d8e73c3af7f189e14f8a170dd78 100644 --- a/layout/_common/sidebar.pug +++ b/layout/_common/sidebar.pug @@ -68,7 +68,7 @@ aside#sidebar span.sidebar-state-item.sidebar-state-posts a(href=menuArchives) div.sidebar-state-item-count= site.posts.length - div.sidebar-state-item-name= _p("sidebar.articles") + div.sidebar-state-item-name= _p("sidebar.archives") if theme.menu.categories span.sidebar-state-item.sidebar-state-categories a(href=menuCategories) diff --git a/scripts/tags/table.js b/scripts/tags/table.js new file mode 100644 index 0000000000000000000000000000000000000000..ccad758ae1a294f4478820f1375c045c6f2370a7 --- /dev/null +++ b/scripts/tags/table.js @@ -0,0 +1,50 @@ +/* global hexo */ + +'use strict'; + +var pathFn = require('path'); +var fs = require('hexo-fs'); + +function table(args) { + args = args.join(' ').split(','); + var path = pathFn.join(hexo.source_dir, args[0]); + var headers = args.slice(1); + + fs.exists(path).then(function(exist) { + if (!exist) { + hexo.log.error('Include file not found!'); + return; + } + }); + + return fs.readFile(path).then(function(data) { + if (!data) { + hexo.log.warn('Include file empty.'); + return; + } + + var data = JSON.parse(data); + var result = ''; + + headers.forEach(item => { + result += ``; + }); + result += ''; + data.forEach(item => { + result += ''; + for (const key in item) { + if (item.hasOwnProperty(key)) { + const value = item[key]; + + result += `` + } + } + result += ''; + }); + result += '
${item.trim()}
${value}
'; + + return result; + }); +} + +hexo.extend.tag.register('table', table, { ends: false, async: true });