Skip to content

Commit 69c85c5

Browse files
committed
tweaks
1 parent 478ea33 commit 69c85c5

File tree

13 files changed

+71
-27
lines changed

13 files changed

+71
-27
lines changed

docs/.vuepress/config.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ module.exports = {
1414
themeConfig: {
1515
logo: `/logo.png`,
1616
repo: 'vuejs/vuepress',
17+
editLinks: true,
1718
docsDir: 'docs',
1819
nav: [
1920
{
@@ -23,6 +24,10 @@ module.exports = {
2324
{
2425
text: 'Config Reference',
2526
link: '/config/'
27+
},
28+
{
29+
text: 'Default Theme Config',
30+
link: '/default-theme-config/'
2631
}
2732
],
2833
sidebar: {
@@ -36,7 +41,6 @@ module.exports = {
3641
'markdown',
3742
'assets',
3843
'using-vue',
39-
'default-theme',
4044
'custom-themes',
4145
'deploy'
4246
]

docs/config/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
### themeConfig
2222

23-
Also see [config options for the default theme](../guide/default-theme.md).
23+
Also see [config options for the default theme](../default-theme-config/).
2424

2525
## Markdown
2626

docs/guide/default-theme.md renamed to docs/default-theme-config/README.md

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
---
2-
prev: ./using-vue
3-
next: ./custom-themes
4-
---
5-
6-
# Default Theme Configuration
1+
# Default Theme Config
72

83
## Accent Color
94

docs/guide/custom-themes.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
prev: ./default-theme
2+
prev: ./using-vue
33
next: ./deploy
44
---
55

docs/guide/getting-started.md

+10
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,13 @@ npm run docs:build
5959
```
6060

6161
By default the built files will be in `.vuepress/dist`, which can be configured via the `dest` field in `.vuepress/config.js`. The built files can be deployed to any static file server. See [Deployment Guide](./deploy.md) for guides on deploying to popular services.
62+
63+
## Basic Configurations
64+
65+
### Title and Description
66+
67+
### Logo
68+
69+
### Navbar Links
70+
71+
### Sidebar

docs/guide/using-vue.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
prev: ./assets
3-
next: ./default-theme
3+
next: ./custom-themes
44
---
55

66
# Using Vue in Markdown

lib/default-theme/Layout.vue

+24-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
<template>
22
<div class="theme-container"
33
:class="{
4+
'no-navbar': !shouldShowNavbar,
45
'sidebar-open': isSidebarOpen,
5-
'no-sidebar': $page.frontmatter.home || $page.frontmatter.sidebar === false
6+
'no-sidebar': !shouldShowSidebar
67
}"
78
@touchstart="onTouchStart"
89
@touchend="onTouchEnd">
9-
<Navbar @toggle-sidebar="toggleSidebar"/>
10+
<Navbar v-if="shouldShowNavbar" @toggle-sidebar="toggleSidebar"/>
1011
<Sidebar @toggle-sidebar="toggleSidebar"/>
1112
<div class="custom-layout" v-if="$page.frontmatter.layout">
1213
<component :is="$page.frontmatter.layout"/>
@@ -33,6 +34,27 @@ export default {
3334
}
3435
},
3536
37+
computed: {
38+
shouldShowNavbar () {
39+
const { themeConfig } = this.$site
40+
return (
41+
this.$site.title ||
42+
themeConfig.logo ||
43+
themeConfig.repo ||
44+
themeConfig.nav
45+
)
46+
},
47+
shouldShowSidebar () {
48+
const { themeConfig } = this.$site
49+
const { frontmatter } = this.$page
50+
return (
51+
themeConfig.sidebar &&
52+
!frontmatter.home &&
53+
frontmatter.sidebar !== false
54+
)
55+
}
56+
},
57+
3658
created () {
3759
if (this.$ssrContext) {
3860
this.$ssrContext.title = getTitle(this.$site, this.$page)

lib/default-theme/NavLinks.vue

+2-3
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,8 @@ export default {
5757
5858
@media (min-width: $MQMobile)
5959
.nav-links a
60-
&:hover:not(.router-link-active)
61-
color $textColor
6260
&:hover, &.router-link-active
61+
color $textColor
6362
margin-bottom -2px
64-
border-bottom 2px solid lighten($accentColor, 10%)
63+
border-bottom 2px solid lighten($accentColor, 5%)
6564
</style>

lib/default-theme/Navbar.vue

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export default {
4848
position relative
4949
top -0.125rem
5050
.links
51+
font-size 0.95rem
5152
float right
5253
a:not(:last-child)
5354
margin-right 1.5rem

lib/default-theme/Page.vue

+9-4
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,18 @@ export default {
4545
docsBranch = 'master'
4646
} = this.$site.themeConfig
4747
48-
const path = normalize(this.$page.path) + '.md'
48+
let path = normalize(this.$page.path)
49+
if (endingSlashRE.test(path)) {
50+
path += 'README.md'
51+
} else {
52+
path += '.md'
53+
}
4954
50-
if (repo && editLinks !== false) {
55+
if (repo && editLinks) {
5156
const base = outboundRE.test(repo)
5257
? repo
5358
: `https://github.com/${repo}`
54-
return base.replace(endingSlashRE, '') + `/edit/${docsBranch}/${docsDir}${path}`
59+
return `${base}/edit/${docsBranch}/${docsDir}${path}`.replace(/\/+/g, '/')
5560
}
5661
}
5762
}
@@ -63,14 +68,14 @@ export default {
6368
6469
.edit-link
6570
padding-top 0 !important
66-
padding-bottom 0 !important
6771
a
6872
color lighten($textColor, 25%)
6973
margin-right 0.25rem
7074
7175
.page-nav.content
7276
min-height 2.2rem
7377
padding-bottom 2rem
78+
padding-top 0.5rem !important
7479
.inner
7580
margin-top 0 !important
7681
border-top 1px solid $borderColor

lib/default-theme/styles/theme.stylus

+14-6
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ body
5252
margin-top $navbarHeight
5353
a:hover
5454
text-decoration underline
55+
p.demo
56+
padding 1rem 1.5rem
57+
border 1px solid #ddd
58+
border-radius 4px
59+
img
60+
max-width $contentWidth
5561

5662
.content.custom
5763
padding 0
@@ -119,12 +125,6 @@ code
119125
p, ul, ol
120126
line-height 1.7
121127

122-
p
123-
&.demo
124-
padding 1rem 1.5rem
125-
border 1px solid #ddd
126-
border-radius 4px
127-
128128
table
129129
border-collapse collapse
130130
margin 1rem 0
@@ -141,9 +141,17 @@ th, td
141141
.custom-layout
142142
padding-top $navbarHeight
143143

144+
.theme-container.no-navbar
145+
.content:not(.custom)
146+
h1, h2, h3, h4, h5, h6
147+
margin-top 1.5rem
148+
padding-top 0
149+
144150
@media (min-width: ($MQMobile + 1px))
145151
.theme-container.no-sidebar
146152
.sidebar
147153
display none
154+
.page
155+
padding-left 0
148156

149157
@import './mobile.stylus'

lib/markdown/link.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ module.exports = md => {
1212
const link = token.attrs[hrefIndex]
1313
const href = link[1]
1414
const isExternal = /^https?:/.test(href)
15-
const isSourceLink = href === '/' || /\.(md|html)(#[\w-]*)?$/.test(href)
15+
const isSourceLink = /(\/|\.md|\.html)(#[\w-]*)?$/.test(href)
1616
if (isExternal) {
1717
const targetIndex = token.attrIndex('target')
1818
if (targetIndex < 0) {

test/simple/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
# Hello VuePress!
1+
# Hello Simple

0 commit comments

Comments
 (0)