Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
大白技术控
yanglr2010
提交
992dbca6
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 搜索 >>
提交
992dbca6
编写于
1月 15, 2020
作者:
EvanOne(文一)
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
style: Format and optimize code
上级
63f19feb
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
36 addition
and
51 deletion
+36
-51
scripts/filters/external-link.js
scripts/filters/external-link.js
+4
-21
scripts/filters/lazyload.js
scripts/filters/lazyload.js
+4
-2
scripts/filters/post-heading.js
scripts/filters/post-heading.js
+2
-2
scripts/filters/resize-img.js
scripts/filters/resize-img.js
+5
-4
scripts/filters/shake-file.js
scripts/filters/shake-file.js
+0
-1
scripts/tags/note.js
scripts/tags/note.js
+9
-8
scripts/tags/table.js
scripts/tags/table.js
+12
-13
未找到文件。
scripts/filters/external-link.js
浏览文件 @
992dbca6
...
...
@@ -15,10 +15,12 @@ hexo.extend.filter.register('after_post_render', function (data) {
var
url
=
require
(
'
url
'
);
var
config
=
this
.
config
;
var
siteHost
=
url
.
parse
(
config
.
url
).
hostname
||
config
.
url
;
// Match only a tags that don't contain html children.
var
regPureATag
=
/<a
([^
>
]
*
)
href="
([^
"
]
*
)
"
([^
>
]
*
)
>
([^
<
]
*
)
<
\/
a>/gim
;
data
.
content
=
data
.
content
.
replace
(
/
(
<a
([^
>
]
*
)
href="
([^
"
]
*
)
"
([^
>
]
*
)
>
([^
<
]
*
)
<
\/
a>
)
/gim
,
function
(
match
,
a
ll
,
a
ttrBegin
,
href
,
attrEnd
,
html
)
{
regPureATag
,
function
(
match
,
attrBegin
,
href
,
attrEnd
,
html
)
{
// Exit if the href attribute doesn't exists.
if
(
!
href
)
{
return
match
;
...
...
@@ -30,25 +32,6 @@ hexo.extend.filter.register('after_post_render', function (data) {
return
match
;
};
var
attrOther
=
attrBegin
+
attrEnd
;
var
className
=
''
;
attrOther
.
split
(
/
\s
/gim
).
forEach
(
attr
=>
{
var
nAttr
=
attr
.
replace
(
/
[
"'
]
*/gim
,
''
);
var
aKey
=
(
nAttr
.
split
(
'
=
'
)[
0
]
||
''
).
trim
();
var
aValue
=
(
nAttr
.
split
(
'
=
'
)[
1
]
||
''
).
trim
();
if
(
aKey
===
'
class
'
)
{
className
=
aValue
;
}
});
// Exit if the class name is in whitelist.
var
whiteList
=
[
'
friends-plugin__item
'
];
if
(
className
&&
whiteList
.
includes
(
className
))
{
return
match
;
}
var
fa_prefix
=
theme
.
fa_prefix
||
'
fa
'
;
return
(
'
<span class="external-link">
'
+
...
...
scripts/filters/lazyload.js
浏览文件 @
992dbca6
...
...
@@ -28,9 +28,11 @@ hexo.extend.filter.register('after_post_render', function (data) {
placeholder
=
loadingBlock
;
}
var
className
=
`lazyload lazyload-
${
phClassName
}
`
;
return
`
<img
${
attrBegin
}
class="lazyload lazyload-
${
phClassName
}
"
src="
${
placeholder
}
" data-src="
${
src
}
"
${
attrEnd
}
>`
;
<img
${
attrBegin
}
class="
${
className
}
"
src="
${
placeholder
}
" data-src="
${
src
}
"
${
attrEnd
}
>
`
;
}
);
},
1
);
scripts/filters/post-heading.js
浏览文件 @
992dbca6
...
...
@@ -19,10 +19,10 @@ hexo.extend.filter.register('after_post_render', function (data) {
return
match
;
}
var
new
Html
=
(
html
.
replace
(
/<
[^
>
]
+>/gim
,
''
)
||
''
).
trim
();
var
filter
Html
=
(
html
.
replace
(
/<
[^
>
]
+>/gim
,
''
)
||
''
).
trim
();
return
`
<h2
${
attrBegin
}
id="
${
id
}
"
${
attrEnd
}
>
<span class="heading-link">
${
new
Html
}
</span>
<span class="heading-link">
${
filter
Html
}
</span>
</h2>
`
;
}
...
...
scripts/filters/resize-img.js
浏览文件 @
992dbca6
...
...
@@ -30,7 +30,10 @@ hexo.extend.filter.register('after_post_render', function (data) {
var
w
=
size
.
split
(
MULTIPLY_SIGN
)[
0
];
var
h
=
size
.
split
(
MULTIPLY_SIGN
)[
1
];
var
style
=
''
;
if
(
!
w
||
!
h
)
{
return
;
}
if
(
w
)
{
style
+=
`width:
${
w
}
px;`
;
}
...
...
@@ -38,9 +41,7 @@ hexo.extend.filter.register('after_post_render', function (data) {
style
+=
`height:
${
h
}
px;`
;
}
var
attr1
=
attrBegin
.
trim
();
var
attr2
=
attrEnd
.
trim
();
return
`<img
${
attr1
}
src="
${
src
}
" style="
${
style
}
"
${
attr2
}
>`
;
return
`<img
${
attrBegin
}
src="
${
src
}
" style="
${
style
}
"
${
attrEnd
}
>`
;
}
);
},
0
);
scripts/filters/shake-file.js
浏览文件 @
992dbca6
...
...
@@ -4,7 +4,6 @@
hexo
.
extend
.
filter
.
register
(
'
after_generate
'
,
function
()
{
var
theme
=
hexo
.
theme
.
config
;
if
(
!
theme
.
shake_file
)
{
return
;
}
...
...
scripts/tags/note.js
浏览文件 @
992dbca6
...
...
@@ -3,14 +3,15 @@
'
use strict
'
;
function
note
(
args
,
content
)
{
var
args
=
args
.
join
(
'
'
);
return
`<div class="note-plugin
${
args
}
">
${
hexo
.
render
.
renderSync
({
text
:
content
,
engine
:
'
markdown
'
})
.
split
(
'
\n
'
)
.
join
(
''
)}
</div>`
;
var
noteClassName
=
args
.
join
(
'
'
);
return
`
<div class="note-plugin
${
noteClassName
}
">
${
hexo
.
render
.
renderSync
({
text
:
content
,
engine
:
'
markdown
'
})
.
split
(
'
\n
'
)
.
join
(
''
)}
</div>
`
;
}
hexo
.
extend
.
tag
.
register
(
'
note
'
,
note
,
{
ends
:
true
});
scripts/tags/table.js
浏览文件 @
992dbca6
...
...
@@ -16,28 +16,27 @@ function table(args) {
}
});
return
fs
.
readFile
(
path
).
then
(
function
(
data
s
)
{
if
(
!
data
s
)
{
return
fs
.
readFile
(
path
).
then
(
function
(
data
)
{
if
(
!
data
)
{
hexo
.
log
.
warn
(
'
Include file empty.
'
);
return
;
}
}
var
datas
=
JSON
.
parse
(
datas
);
var
tableData
=
JSON
.
parse
(
data
);
var
result
=
'
<table class="table-plugin"><thead><tr>
'
;
headers
.
forEach
(
header
=>
{
result
+=
`<th>
${
header
}
</th>`
;
});
headers
.
forEach
(
header
=>
(
result
+=
`<th>
${
header
}
</th>`
));
result
+=
'
</tr></thead><tbody>
'
;
datas
.
forEach
(
data
=>
{
tableData
.
forEach
(
item
=>
{
result
+=
'
<tr style="text-align: center;">
'
;
for
(
const
key
in
data
)
{
if
(
data
.
hasOwnProperty
(
key
)
)
{
const
value
=
data
[
key
];
result
+=
`<td>
${
value
}
</td>`
for
(
var
key
in
item
)
{
if
(
item
.
hasOwnProperty
(
key
))
{
var
value
=
item
[
key
];
result
+=
`<td>
${
value
}
</td>`
;
}
}
result
+=
'
</tr>
'
;
});
result
+=
'
</tbody></table>
'
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录