Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
计算机应用开发
前端
Vuepress
提交
16150786
V
Vuepress
项目概览
计算机应用开发
/
前端
/
Vuepress
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
Vuepress
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
16150786
编写于
4月 11, 2018
作者:
E
Evan You
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
auto extract h2 headers
上级
239907fe
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
51 addition
and
18 deletion
+51
-18
lib/default-theme/NavLinks.vue
lib/default-theme/NavLinks.vue
+11
-5
lib/default-theme/SidebarLink.vue
lib/default-theme/SidebarLink.vue
+34
-11
lib/prepare.js
lib/prepare.js
+5
-1
lib/util.js
lib/util.js
+1
-1
未找到文件。
lib/default-theme/NavLinks.vue
浏览文件 @
16150786
...
...
@@ -49,11 +49,17 @@ export default {
<
style
lang=
"stylus"
>
@import './styles/config.stylus'
.nav-links
a
color inherit
font-weight 500
line-height 1.5
.nav-links a
color inherit
font-weight 500
line-height 1.5
&:hover, &.active
color $accentColor
@media (min-width: $MQMobile)
.nav-links a
&:hover:not(.active)
color $textColor
&:hover, &.active
margin-bottom -2px
border-bottom 2px solid lighten($accentColor, 10%)
...
...
lib/default-theme/SidebarLink.vue
浏览文件 @
16150786
...
...
@@ -5,19 +5,35 @@ export default {
functional
:
true
,
props
:
[
'
item
'
],
render
(
h
,
{
parent
:
{
$route
},
props
:
{
item
}})
{
return
h
(
'
router-link
'
,
{
props
:
{
to
:
item
.
path
},
class
:
{
'
sidebar-link
'
:
true
,
// use custom active class matching logic
// due to edge case of paths ending with / + hash
active
:
isActive
(
$route
,
item
.
path
)
}
},
[
item
.
title
||
item
.
path
])
// use custom active class matching logic
// due to edge case of paths ending with / + hash
const
active
=
isActive
(
$route
,
item
.
path
)
const
link
=
renderLink
(
h
,
item
.
path
,
item
.
title
||
item
.
path
,
active
)
return
active
&&
item
.
headers
?
[
link
,
renderChildren
(
h
,
item
,
$route
)]
:
link
}
}
function
renderLink
(
h
,
to
,
text
,
active
)
{
return
h
(
'
router-link
'
,
{
props
:
{
to
},
class
:
{
active
,
'
sidebar-link
'
:
true
}
},
text
)
}
function
renderChildren
(
h
,
{
path
,
headers
},
route
)
{
headers
=
headers
.
filter
(
h
=>
h
.
level
===
2
)
return
h
(
'
ul
'
,
{
class
:
'
sidebar-sub-headers
'
},
headers
.
map
(
c
=>
{
const
active
=
isActive
(
route
,
path
+
'
#
'
+
c
.
slug
)
return
h
(
'
li
'
,
{
class
:
'
sidebar-sub-header
'
},
[
renderLink
(
h
,
'
#
'
+
c
.
slug
,
c
.
title
,
active
)
])
}))
}
</
script
>
<
style
lang=
"stylus"
>
...
...
@@ -38,4 +54,11 @@ a.sidebar-link
border-left-color $accentColor
.sidebar-group &
padding-left 2rem
.sidebar-sub-headers &
padding-left 3.25rem
padding-top 0
border-left none
font-size 0.95em
&.active
font-weight 500
</
style
>
lib/prepare.js
浏览文件 @
16150786
...
...
@@ -4,7 +4,7 @@ const globby = require('globby')
const
mkdirp
=
require
(
'
mkdirp
'
)
const
yaml
=
require
(
'
yaml-front-matter
'
)
const
tempPath
=
path
.
resolve
(
__dirname
,
'
app/.temp
'
)
const
{
inferTitle
}
=
require
(
'
./util
'
)
const
{
inferTitle
,
extractHeaders
}
=
require
(
'
./util
'
)
mkdirp
(
tempPath
)
...
...
@@ -116,6 +116,10 @@ async function resolveOptions (sourceDir) {
if
(
title
)
{
data
.
title
=
title
}
const
headers
=
extractHeaders
(
frontmatter
.
__content
,
[
'
h2
'
,
'
h3
'
])
if
(
headers
.
length
)
{
data
.
headers
=
headers
}
delete
frontmatter
.
__content
if
(
Object
.
keys
(
frontmatter
).
length
)
{
data
.
frontmatter
=
frontmatter
...
...
lib/util.js
浏览文件 @
16150786
...
...
@@ -52,7 +52,7 @@ exports.extractHeaders = (content, include = []) => {
res
.
push
({
level
:
parseInt
(
t
.
tag
.
slice
(
1
),
10
),
title
,
slug
:
S
(
title
).
slugify
()
slug
:
S
(
title
).
slugify
()
.
s
})
}
})
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录