Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
大白技术控
yanglr2010
提交
1d86188a
Y
yanglr2010
项目概览
大白技术控
/
yanglr2010
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Y
yanglr2010
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
1d86188a
编写于
8月 02, 2019
作者:
EvanOne(文一)
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: Add tag plugin of 'table'
上级
0699e519
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
117 addition
and
6 deletion
+117
-6
docs/zh-CN/advanced/assist.md
docs/zh-CN/advanced/assist.md
+61
-2
docs/zh-CN/advanced/theme-config.md
docs/zh-CN/advanced/theme-config.md
+1
-1
languages/en.yml
languages/en.yml
+2
-1
languages/zh-CN.yml
languages/zh-CN.yml
+2
-1
layout/_common/sidebar.pug
layout/_common/sidebar.pug
+1
-1
scripts/tags/table.js
scripts/tags/table.js
+50
-0
未找到文件。
docs/zh-CN/advanced/assist.md
浏览文件 @
1d86188a
...
...
@@ -2,7 +2,7 @@
## 快捷键
-
快速切换文章
<Badge
text=
"beta"
type=
"warn"
/>
<Badge
text=
"v1.1.3"
/>
###
快速切换文章 <Badge text="beta" type="warn"/> <Badge text="v1.1.3"/>
::: tip
该功能在
`v1.1.0`
版本中快捷键为(
`←`
:切换到上一篇文章,
`→`
:切换到下一篇文章),在
`v1.1.3`
版本中快捷键修改为(Ctrl +
`←`
,Ctrl +
`→`
)。
...
...
@@ -24,6 +24,65 @@ shortcuts:
> 考虑到这里的快捷键可能会和用户系统或软件的冲突,所以在 Stun 主题 `v1.1.3` 版本中,这个功能加入了配置项,用户可以自己决定是否开启,默认不启用。并且在 Stun 主题以后的版本中,可能会留出配置项让用户自定义快捷键。
-
快速关闭搜索框
<Badge
text=
"stable"
/>
<Badge
text=
"v1.0.3"
/>
###
快速关闭搜索框 <Badge text="stable"/> <Badge text="v1.0.3"/>
关闭搜索框有三种方式,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 主题也有自己扩展的一些标签插件,这些标签插件如下:
### 插入表格数据 <Badge text="stable"/> <Badge text="v1.2.0"/>
如果想要在文章中显示一个表格,你可以使用 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
)
docs/zh-CN/advanced/theme-config.md
浏览文件 @
1d86188a
...
...
@@ -941,7 +941,7 @@ external_link:
color: "#aaa"
```
## FancyBox <Badge text="stable"/> <Badge text="v1.1.4"/>
##
#
FancyBox <Badge text="stable"/> <Badge text="v1.1.4"/>
如果想要使用 fancybox 功能,只需要修改主题配置文件即可:
...
...
languages/en.yml
浏览文件 @
1d86188a
...
...
@@ -27,7 +27,7 @@ sidebar:
overview
:
Overview
catalog
:
Catalog
subscribe
:
Subscribe
ar
ticles
:
Articl
es
ar
chives
:
Archiv
es
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
...
...
languages/zh-CN.yml
浏览文件 @
1d86188a
...
...
@@ -27,7 +27,7 @@ sidebar:
overview
:
站点概览
catalog
:
文章目录
subscribe
:
订阅
ar
ticles
:
文章
ar
chives
:
归档
categories
:
分类
tags
:
标签
read_info
:
你已阅读了
...
...
@@ -92,6 +92,7 @@ footer:
uv
:
访问人数
pv
:
浏览总量
# 全局消息提示信息
notification
:
copy
:
success
:
复制成功
...
...
layout/_common/sidebar.pug
浏览文件 @
1d86188a
...
...
@@ -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.ar
ticl
es")
div.sidebar-state-item-name= _p("sidebar.ar
chiv
es")
if theme.menu.categories
span.sidebar-state-item.sidebar-state-categories
a(href=menuCategories)
...
...
scripts/tags/table.js
0 → 100644
浏览文件 @
1d86188a
/* 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
=
'
<table><thead><tr>
'
;
headers
.
forEach
(
item
=>
{
result
+=
`<th>
${
item
.
trim
()}
</th>`
;
});
result
+=
'
</tr></thead><tbody>
'
;
data
.
forEach
(
item
=>
{
result
+=
'
<tr style="text-align: center;">
'
;
for
(
const
key
in
item
)
{
if
(
item
.
hasOwnProperty
(
key
))
{
const
value
=
item
[
key
];
result
+=
`<td>
${
value
}
</td>`
}
}
result
+=
'
</tr>
'
;
});
result
+=
'
</tbody></table>
'
;
return
result
;
});
}
hexo
.
extend
.
tag
.
register
(
'
table
'
,
table
,
{
ends
:
false
,
async
:
true
});
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录