Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
计算机应用开发
前端
Vuepress
提交
a1bed8d4
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,发现更多精彩内容 >>
提交
a1bed8d4
编写于
4月 12, 2018
作者:
E
Evan You
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
simple search
上级
da7b258d
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
223 addition
and
28 deletion
+223
-28
docs/.vuepress/config.js
docs/.vuepress/config.js
+15
-4
docs/guide/README.md
docs/guide/README.md
+4
-0
lib/default-theme/NavLinks.vue
lib/default-theme/NavLinks.vue
+15
-8
lib/default-theme/Navbar.vue
lib/default-theme/Navbar.vue
+10
-8
lib/default-theme/SearchBox.vue
lib/default-theme/SearchBox.vue
+172
-3
lib/default-theme/Sidebar.vue
lib/default-theme/Sidebar.vue
+1
-3
lib/default-theme/search.svg
lib/default-theme/search.svg
+1
-0
lib/default-theme/styles/theme.stylus
lib/default-theme/styles/theme.stylus
+2
-2
lib/util.js
lib/util.js
+3
-0
未找到文件。
docs/.vuepress/config.js
浏览文件 @
a1bed8d4
...
@@ -49,12 +49,23 @@ module.exports = {
...
@@ -49,12 +49,23 @@ module.exports = {
{
{
title
:
'
Config Reference
'
,
title
:
'
Config Reference
'
,
collapsable
:
false
,
collapsable
:
false
,
children
:
extractHeaders
(
children
:
genSidebar
(
'
config/README.md
'
)
fs
.
readFileSync
(
path
.
resolve
(
__dirname
,
'
../config/README.md
'
),
'
utf-8
'
),
}
[
'
h3
'
]
],
).
map
(({
title
,
slug
})
=>
[
`#
${
slug
}
`
,
title
])
'
/default-theme-config/
'
:
[
{
title
:
'
Default Theme Config
'
,
collapsable
:
false
,
children
:
genSidebar
(
'
default-theme-config/README.md
'
)
}
}
]
]
}
}
}
}
}
}
function
genSidebar
(
file
)
{
return
extractHeaders
(
fs
.
readFileSync
(
path
.
resolve
(
__dirname
,
'
../
'
,
file
),
'
utf-8
'
),
[
'
h3
'
]
).
map
(({
title
,
slug
})
=>
[
`#
${
slug
}
`
,
title
])
}
docs/guide/README.md
浏览文件 @
a1bed8d4
...
@@ -8,6 +8,10 @@ next: ./getting-started
...
@@ -8,6 +8,10 @@ next: ./getting-started
## Todo Features
## Todo Features
### PWA Support
### Algolia DocSearch Integration
## Why Not ...?
## Why Not ...?
### Nuxt / NuxtDoc
### Nuxt / NuxtDoc
...
...
lib/default-theme/NavLinks.vue
浏览文件 @
a1bed8d4
<
template
>
<
template
>
<
di
v
class=
"nav-links"
>
<
na
v
class=
"nav-links"
>
<!-- user links -->
<!-- user links -->
<router-link
v-for=
"item in userLinks"
<router-link
v-for=
"item in userLinks"
:to=
"item.link"
:to=
"item.link"
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
Github
Github
<OutboundLink/>
<OutboundLink/>
</a>
</a>
</
di
v>
</
na
v>
</
template
>
</
template
>
<
script
>
<
script
>
...
@@ -48,12 +48,19 @@ export default {
...
@@ -48,12 +48,19 @@ export default {
<
style
lang=
"stylus"
>
<
style
lang=
"stylus"
>
@import './styles/config.stylus'
@import './styles/config.stylus'
.nav-links a
.nav-links
color inherit
display inline-block
font-weight 500
a
line-height 1.5
color inherit
&:hover, &.router-link-active
font-weight 500
color $accentColor
line-height 1.25rem
margin-left 1.5rem
&:hover, &.router-link-active
color $accentColor
@media (max-width: $MQMobile)
.nav-links a
margin-left 0
@media (min-width: $MQMobile)
@media (min-width: $MQMobile)
.nav-links a
.nav-links a
...
...
lib/default-theme/Navbar.vue
浏览文件 @
a1bed8d4
<
template
>
<
template
>
<
div
class=
"navbar"
>
<
header
class=
"navbar"
>
<SidebarButton
@
toggle-sidebar=
"$emit('toggle-sidebar')"
/>
<SidebarButton
@
toggle-sidebar=
"$emit('toggle-sidebar')"
/>
<router-link
to=
"/"
>
<router-link
to=
"/"
>
<img
class=
"logo"
<img
class=
"logo"
...
@@ -12,18 +12,19 @@
...
@@ -12,18 +12,19 @@
</span>
</span>
</router-link>
</router-link>
<div
class=
"links"
>
<div
class=
"links"
>
<
!-- search box --
>
<
SearchBox/
>
<NavLinks
class=
"can-hide"
/>
<NavLinks
class=
"can-hide"
/>
</div>
</div>
</
div
>
</
header
>
</
template
>
</
template
>
<
script
>
<
script
>
import
SidebarButton
from
'
./SidebarButton.vue
'
import
SidebarButton
from
'
./SidebarButton.vue
'
import
SearchBox
from
'
./SearchBox.vue
'
import
NavLinks
from
'
./NavLinks.vue
'
import
NavLinks
from
'
./NavLinks.vue
'
export
default
{
export
default
{
components
:
{
SidebarButton
,
NavLinks
}
components
:
{
SidebarButton
,
NavLinks
,
SearchBox
}
}
}
</
script
>
</
script
>
...
@@ -33,6 +34,7 @@ export default {
...
@@ -33,6 +34,7 @@ export default {
.navbar
.navbar
padding 0.7rem 1.5rem
padding 0.7rem 1.5rem
line-height 2rem
line-height 2rem
position relative
a, span, img
a, span, img
vertical-align middle
vertical-align middle
display inline-block
display inline-block
...
@@ -48,10 +50,10 @@ export default {
...
@@ -48,10 +50,10 @@ export default {
position relative
position relative
top -0.125rem
top -0.125rem
.links
.links
font-size 0.9
5
rem
font-size 0.9rem
float right
position absolute
a:not(:last-child)
right 1.5rem
margin-right 1.5
rem
top 0.7
rem
@media (max-width: $MQMobile)
@media (max-width: $MQMobile)
.navbar
.navbar
...
...
lib/default-theme/SearchBox.vue
浏览文件 @
a1bed8d4
<
template
>
<
template
>
<span>
<div
class=
"search-box"
>
<input
v-model=
"query"
</span>
autocomplete=
"off"
spellcheck=
"false"
@
focus=
"focused = true"
@
blur=
"focused = false"
@
keyup.enter=
"go(focusIndex)"
@
keyup.up=
"onUp"
@
keyup.down=
"onDown"
>
<ul
class=
"suggestions"
v-if=
"showSuggestions"
@
mouseleave=
"unfocus"
>
<li
class=
"suggestion"
v-for=
"(s, i) in suggestions"
:class=
"
{ focused: i === focusIndex }"
@mousedown="go(i)"
@mouseenter="focus(i)">
<a
:href=
"s.path"
@
click.prevent
>
<span
class=
"page-title"
>
{{
s
.
title
||
s
.
path
}}
</span>
<span
v-if=
"s.header"
class=
"header"
>
>
{{
s
.
header
.
title
}}
</span>
</a>
</li>
</ul>
</div>
</
template
>
</
template
>
<
script
>
<
script
>
export
default
{
data
()
{
return
{
query
:
''
,
focused
:
false
,
focusIndex
:
0
}
},
computed
:
{
showSuggestions
()
{
return
(
this
.
focused
&&
this
.
suggestions
&&
this
.
suggestions
.
length
)
},
suggestions
()
{
const
query
=
this
.
query
.
trim
().
toLowerCase
()
if
(
!
query
)
{
return
}
const
max
=
5
const
{
pages
}
=
this
.
$site
const
matches
=
item
=>
(
item
.
title
&&
item
.
title
.
toLowerCase
().
indexOf
(
query
)
>
-
1
)
const
res
=
[]
for
(
let
i
=
0
;
i
<
pages
.
length
;
i
++
)
{
if
(
res
.
length
>=
max
)
break
const
p
=
pages
[
i
]
if
(
matches
(
p
))
{
res
.
push
(
p
)
}
else
if
(
p
.
headers
)
{
for
(
let
j
=
0
;
j
<
p
.
headers
.
length
;
j
++
)
{
if
(
res
.
length
>=
max
)
break
const
h
=
p
.
headers
[
j
]
if
(
matches
(
h
))
{
res
.
push
(
Object
.
assign
({},
p
,
{
path
:
p
.
path
+
'
#
'
+
h
.
slug
,
header
:
h
}))
}
}
}
}
return
res
}
},
methods
:
{
onClick
()
{
console
.
log
(
'
clicked
'
)
},
onUp
()
{
if
(
this
.
showSuggestions
)
{
if
(
this
.
focusIndex
>
0
)
{
this
.
focusIndex
--
}
else
{
this
.
focusIndex
=
this
.
suggestions
.
length
-
1
}
}
},
onDown
()
{
if
(
this
.
showSuggestions
)
{
if
(
this
.
focusIndex
<
this
.
suggestions
.
length
-
1
)
{
this
.
focusIndex
++
}
else
{
this
.
focusIndex
=
0
}
}
},
go
(
i
)
{
this
.
$router
.
push
(
this
.
suggestions
[
i
].
path
)
this
.
query
=
''
this
.
focusIndex
=
0
},
focus
(
i
)
{
this
.
focusIndex
=
i
},
unfocus
()
{
this
.
focusIndex
=
-
1
}
}
}
</
script
>
</
script
>
<
style
lang=
"stylus"
>
@import './styles/config.stylus'
.search-box
display inline-block
position relative
margin-right 0.5rem
input
cursor pointer
width 10rem
color lighten($textColor, 25%)
display inline-block
border 1px solid darken($borderColor, 10%)
border-radius 2rem
font-size 0.9rem
line-height 2rem
padding 0 0.5rem 0 2rem
outline none
transition all .2s ease
background #fff url(./search.svg) 0.6rem 0.5rem no-repeat
background-size 1rem
&:focus
cursor auto
border-color $accentColor
.suggestions
background #fff
width 20rem
position absolute
top 1.5rem
border 1px solid darken($borderColor, 10%)
border-radius 6px
padding 0.4rem 0
list-style-type none
.suggestion
line-height 1.4
padding 0.4rem 1rem
a
color lighten($textColor, 20%)
.page-title
font-weight 600
.header
font-size 0.9em
margin-left 0.25em
&.focused
background-color $lighten($textColor, 50%)
a
color $accentColor
@media (max-width: $MQNarrow)
.search-box input
width 0
border-color transparent
position relative
left 1rem
&:focus
left 0.5rem
width 10rem
@media (max-width: $MQMobile)
.search-box
margin-right 0
.suggestions
right -0.5rem
</
style
>
lib/default-theme/Sidebar.vue
浏览文件 @
a1bed8d4
<
template
>
<
template
>
<div
class=
"sidebar"
>
<div
class=
"sidebar"
>
<SidebarButton
@
toggle-sidebar=
"$emit('toggle-sidebar')"
/>
<NavLinks/>
<NavLinks/>
<ul>
<ul>
<li
v-for=
"(item, i) in sidebarItems"
>
<li
v-for=
"(item, i) in sidebarItems"
>
...
@@ -19,12 +18,11 @@
...
@@ -19,12 +18,11 @@
<
script
>
<
script
>
import
SidebarGroup
from
'
./SidebarGroup.vue
'
import
SidebarGroup
from
'
./SidebarGroup.vue
'
import
SidebarLink
from
'
./SidebarLink.vue
'
import
SidebarLink
from
'
./SidebarLink.vue
'
import
SidebarButton
from
'
./SidebarButton.vue
'
import
NavLinks
from
'
./NavLinks.vue
'
import
NavLinks
from
'
./NavLinks.vue
'
import
{
resolvePage
,
isActive
}
from
'
./util
'
import
{
resolvePage
,
isActive
}
from
'
./util
'
export
default
{
export
default
{
components
:
{
SidebarGroup
,
SidebarLink
,
SidebarButton
,
NavLinks
},
components
:
{
SidebarGroup
,
SidebarLink
,
NavLinks
},
data
()
{
data
()
{
return
{
return
{
openGroupIndex
:
0
openGroupIndex
:
0
...
...
lib/default-theme/search.svg
0 → 100644
浏览文件 @
a1bed8d4
<?xml version="1.0" encoding="UTF-8"?>
<svg
xmlns=
"http://www.w3.org/2000/svg"
width=
"12"
height=
"13"
><g
stroke-width=
"2"
stroke=
"#aaa"
fill=
"none"
><path
d=
"M11.29 11.71l-4-4"
/><circle
cx=
"5"
cy=
"5"
r=
"4"
/></g></svg>
lib/default-theme/styles/theme.stylus
浏览文件 @
a1bed8d4
...
@@ -20,7 +20,7 @@ body
...
@@ -20,7 +20,7 @@ body
.navbar
.navbar
position fixed
position fixed
z-index
1
0
z-index
2
0
top 0
top 0
left 0
left 0
right 0
right 0
...
@@ -34,7 +34,7 @@ body
...
@@ -34,7 +34,7 @@ body
background-color #fff
background-color #fff
width $sidebarWidth
width $sidebarWidth
position fixed
position fixed
z-index
2
0
z-index
1
0
margin 0
margin 0
top $navbarHeight
top $navbarHeight
left 0
left 0
...
...
lib/util.js
浏览文件 @
a1bed8d4
...
@@ -26,6 +26,9 @@ exports.applyUserWebpackConfig = function (userConfig, config, isServer) {
...
@@ -26,6 +26,9 @@ exports.applyUserWebpackConfig = function (userConfig, config, isServer) {
}
}
exports
.
inferTitle
=
function
(
frontmatter
)
{
exports
.
inferTitle
=
function
(
frontmatter
)
{
if
(
frontmatter
.
home
)
{
return
'
Home
'
}
if
(
frontmatter
.
title
)
{
if
(
frontmatter
.
title
)
{
return
frontmatter
.
title
return
frontmatter
.
title
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录