Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
大白技术控
yanglr2010
提交
625f6232
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,发现更多精彩内容 >>
提交
625f6232
编写于
8月 03, 2019
作者:
EvanOne(文一)
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: Modify arguments of tag plugin
上级
c9d5e81c
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
49 addition
and
28 deletion
+49
-28
docs/zh-CN/advanced/assist.md
docs/zh-CN/advanced/assist.md
+27
-7
scripts/tags/note.js
scripts/tags/note.js
+3
-1
scripts/tags/table.js
scripts/tags/table.js
+10
-11
source/css/_components/tag-plugin/note.styl
source/css/_components/tag-plugin/note.styl
+9
-9
未找到文件。
docs/zh-CN/advanced/assist.md
浏览文件 @
625f6232
...
...
@@ -36,19 +36,19 @@ Hexo 主题一般都会扩展一些自己特有的标签插件,在这方面做
此外,Stun 主题也有自己扩展的一些标签插件,这些标签插件如下:
### 插入表格数据 <Badge text="
stable
"/> <Badge text="v1.2.0"/>
### 插入表格数据 <Badge text="
beta" type="warning
"/> <Badge text="v1.2.0"/>
如果想要在文章中显示一个表格,你可以使用 markdown 原生支持的语法,但是如果你想要让表格里的数据存储在外部文件中,那么你可以使用下面这种语法:
```
{% table [path]
, [thead1, thead2,
...] %}
{% table [path]
[thead1,thead2,
...] %}
```
参数:
`[path]`
:数据文件的路径
`[thead1,
thead2, ...]`
:表格头部的文字(表格有几列就要写几项
)
`[thead1,
thead2,...]`
:表格头部的文字(用半角逗号分隔,逗号前后不要有空格
)
::: warning
数据文件必须放在
`/source/`
目录下,建议放在
`/source/_data/`
目录下。
...
...
@@ -80,14 +80,14 @@ Hexo 主题一般都会扩展一些自己特有的标签插件,在这方面做
2.
在文章或页面的 markdown 源文件中,插入如下标签。
```
{% table _data/reward.json
, 时间, 赞助人, 金额,
留言 %}
{% table _data/reward.json
时间,赞助人,金额,
留言 %}
```
3.
重启 Hexo 服务器,效果如下。
![](
https://raw.githubusercontent.com/liuyib/picBed/master/hexo-theme-stun/doc/20190802171506.png
)
### Bootstrap 标注 <Badge text="
stable
"/> <Badge text="v1.2.0"/>
### Bootstrap 标注 <Badge text="
beta" type="warning
"/> <Badge text="v1.2.0"/>
语法如下:
...
...
@@ -109,14 +109,34 @@ any text
举例:
```
```
md
<!-- header icon -->
{% note success %}
**Success**
This is success note.
{% endnote %}
<!-- header no-icon -->
{% note success no-icon %}
**Success**
This is success note.
{% endnote %}
<!-- no-header icon -->
{% note success %}
This is success note.
{% endnote %}
<!-- no-header no-icon -->
{% note success no-icon %}
This is success note.
{% endnote %}
```
全部效果如下:
![](
https://raw.githubusercontent.com/liuyib/picBed/master/hexo-theme-stun/doc/20190802221712.png
)
![](
https://raw.githubusercontent.com/liuyib/picBed/master/hexo-theme-stun/doc/20190803082614.png
)
![](
https://raw.githubusercontent.com/liuyib/picBed/master/hexo-theme-stun/doc/20190803081736.png
)
scripts/tags/note.js
浏览文件 @
625f6232
...
...
@@ -3,7 +3,9 @@
'
use strict
'
;
function
note
(
args
,
content
)
{
return
`<div class="note-plugin
${
args
.
join
(
'
'
)}
">
var
args
=
args
.
join
(
'
'
);
return
`<div class="note-plugin
${
args
}
">
${
hexo
.
render
.
renderSync
({
text
:
content
,
engine
:
'
markdown
'
})
.
split
(
'
\n
'
)
...
...
scripts/tags/table.js
浏览文件 @
625f6232
...
...
@@ -6,9 +6,8 @@ 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
);
var
headers
=
args
[
1
].
split
(
'
,
'
);
fs
.
exists
(
path
).
then
(
function
(
exist
)
{
if
(
!
exist
)
{
...
...
@@ -17,24 +16,24 @@ function table(args) {
}
});
return
fs
.
readFile
(
path
).
then
(
function
(
data
)
{
if
(
!
data
)
{
return
fs
.
readFile
(
path
).
then
(
function
(
data
s
)
{
if
(
!
data
s
)
{
hexo
.
log
.
warn
(
'
Include file empty.
'
);
return
;
}
var
data
=
JSON
.
parse
(
data
);
var
data
s
=
JSON
.
parse
(
datas
);
var
result
=
'
<table><thead><tr>
'
;
headers
.
forEach
(
item
=>
{
result
+=
`<th>
${
item
.
trim
()
}
</th>`
;
headers
.
forEach
(
header
=>
{
result
+=
`<th>
${
header
}
</th>`
;
});
result
+=
'
</tr></thead><tbody>
'
;
data
.
forEach
(
item
=>
{
data
s
.
forEach
(
data
=>
{
result
+=
'
<tr style="text-align: center;">
'
;
for
(
const
key
in
item
)
{
if
(
item
.
hasOwnProperty
(
key
))
{
const
value
=
item
[
key
];
for
(
const
key
in
data
)
{
if
(
data
.
hasOwnProperty
(
key
))
{
const
value
=
data
[
key
];
result
+=
`<td>
${
value
}
</td>`
}
...
...
source/css/_components/tag-plugin/note.styl
浏览文件 @
625f6232
...
...
@@ -22,15 +22,15 @@
&.success::before
content: '\f058'
color: #
5cb85c
color: #
42b983
&.warning::before
content: '\f06a'
color: #
f0ad4
e
color: #
ecc91
e
&.danger::before
content: '\f056'
color: #d
9534f
color: #d
c3b3b
&.default
border-left-color: #777
...
...
@@ -39,22 +39,22 @@
color: #777
&.success
border-left-color: #
5cb85c
border-left-color: #
42b983
strong
color: #
5cb85c
color: #
42b983
&.warning
border-left-color: #
f0ad4
e
border-left-color: #
ecc91
e
strong
color: #
f0ad4
e
color: #
ecc91
e
&.danger
border-left-color: #d
9534f
border-left-color: #d
c3b3b
strong
color: #d
9534f
color: #d
c3b3b
h1, h2, h3, h4, h5, h6
margin: 0
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录