Skip to content

Commit

Permalink
tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Apr 11, 2018
1 parent 478ea33 commit 69c85c5
Show file tree
Hide file tree
Showing 13 changed files with 71 additions and 27 deletions.
6 changes: 5 additions & 1 deletion docs/.vuepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ module.exports = {
themeConfig: {
logo: `/logo.png`,
repo: 'vuejs/vuepress',
editLinks: true,
docsDir: 'docs',
nav: [
{
Expand All @@ -23,6 +24,10 @@ module.exports = {
{
text: 'Config Reference',
link: '/config/'
},
{
text: 'Default Theme Config',
link: '/default-theme-config/'
}
],
sidebar: {
Expand All @@ -36,7 +41,6 @@ module.exports = {
'markdown',
'assets',
'using-vue',
'default-theme',
'custom-themes',
'deploy'
]
Expand Down
2 changes: 1 addition & 1 deletion docs/config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

### themeConfig

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

## Markdown

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
---
prev: ./using-vue
next: ./custom-themes
---

# Default Theme Configuration
# Default Theme Config

## Accent Color

Expand Down
2 changes: 1 addition & 1 deletion docs/guide/custom-themes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
prev: ./default-theme
prev: ./using-vue
next: ./deploy
---

Expand Down
10 changes: 10 additions & 0 deletions docs/guide/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,13 @@ npm run docs:build
```

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.

## Basic Configurations

### Title and Description

### Logo

### Navbar Links

### Sidebar
2 changes: 1 addition & 1 deletion docs/guide/using-vue.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
prev: ./assets
next: ./default-theme
next: ./custom-themes
---

# Using Vue in Markdown
Expand Down
26 changes: 24 additions & 2 deletions lib/default-theme/Layout.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<template>
<div class="theme-container"
:class="{
'no-navbar': !shouldShowNavbar,
'sidebar-open': isSidebarOpen,
'no-sidebar': $page.frontmatter.home || $page.frontmatter.sidebar === false
'no-sidebar': !shouldShowSidebar
}"
@touchstart="onTouchStart"
@touchend="onTouchEnd">
<Navbar @toggle-sidebar="toggleSidebar"/>
<Navbar v-if="shouldShowNavbar" @toggle-sidebar="toggleSidebar"/>
<Sidebar @toggle-sidebar="toggleSidebar"/>
<div class="custom-layout" v-if="$page.frontmatter.layout">
<component :is="$page.frontmatter.layout"/>
Expand All @@ -33,6 +34,27 @@ export default {
}
},
computed: {
shouldShowNavbar () {
const { themeConfig } = this.$site
return (
this.$site.title ||
themeConfig.logo ||
themeConfig.repo ||
themeConfig.nav
)
},
shouldShowSidebar () {
const { themeConfig } = this.$site
const { frontmatter } = this.$page
return (
themeConfig.sidebar &&
!frontmatter.home &&
frontmatter.sidebar !== false
)
}
},
created () {
if (this.$ssrContext) {
this.$ssrContext.title = getTitle(this.$site, this.$page)
Expand Down
5 changes: 2 additions & 3 deletions lib/default-theme/NavLinks.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,8 @@ export default {
@media (min-width: $MQMobile)
.nav-links a
&:hover:not(.router-link-active)
color $textColor
&:hover, &.router-link-active
color $textColor
margin-bottom -2px
border-bottom 2px solid lighten($accentColor, 10%)
border-bottom 2px solid lighten($accentColor, 5%)
</style>
1 change: 1 addition & 0 deletions lib/default-theme/Navbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export default {
position relative
top -0.125rem
.links
font-size 0.95rem
float right
a:not(:last-child)
margin-right 1.5rem
Expand Down
13 changes: 9 additions & 4 deletions lib/default-theme/Page.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,18 @@ export default {
docsBranch = 'master'
} = this.$site.themeConfig
const path = normalize(this.$page.path) + '.md'
let path = normalize(this.$page.path)
if (endingSlashRE.test(path)) {
path += 'README.md'
} else {
path += '.md'
}
if (repo && editLinks !== false) {
if (repo && editLinks) {
const base = outboundRE.test(repo)
? repo
: `https://github.com/${repo}`
return base.replace(endingSlashRE, '') + `/edit/${docsBranch}/${docsDir}${path}`
return `${base}/edit/${docsBranch}/${docsDir}${path}`.replace(/\/+/g, '/')
}
}
}
Expand All @@ -63,14 +68,14 @@ export default {
.edit-link
padding-top 0 !important
padding-bottom 0 !important
a
color lighten($textColor, 25%)
margin-right 0.25rem
.page-nav.content
min-height 2.2rem
padding-bottom 2rem
padding-top 0.5rem !important
.inner
margin-top 0 !important
border-top 1px solid $borderColor
Expand Down
20 changes: 14 additions & 6 deletions lib/default-theme/styles/theme.stylus
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ body
margin-top $navbarHeight
a:hover
text-decoration underline
p.demo
padding 1rem 1.5rem
border 1px solid #ddd
border-radius 4px
img
max-width $contentWidth

.content.custom
padding 0
Expand Down Expand Up @@ -119,12 +125,6 @@ code
p, ul, ol
line-height 1.7

p
&.demo
padding 1rem 1.5rem
border 1px solid #ddd
border-radius 4px

table
border-collapse collapse
margin 1rem 0
Expand All @@ -141,9 +141,17 @@ th, td
.custom-layout
padding-top $navbarHeight

.theme-container.no-navbar
.content:not(.custom)
h1, h2, h3, h4, h5, h6
margin-top 1.5rem
padding-top 0

@media (min-width: ($MQMobile + 1px))
.theme-container.no-sidebar
.sidebar
display none
.page
padding-left 0

@import './mobile.stylus'
2 changes: 1 addition & 1 deletion lib/markdown/link.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module.exports = md => {
const link = token.attrs[hrefIndex]
const href = link[1]
const isExternal = /^https?:/.test(href)
const isSourceLink = href === '/' || /\.(md|html)(#[\w-]*)?$/.test(href)
const isSourceLink = /(\/|\.md|\.html)(#[\w-]*)?$/.test(href)
if (isExternal) {
const targetIndex = token.attrIndex('target')
if (targetIndex < 0) {
Expand Down
2 changes: 1 addition & 1 deletion test/simple/README.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# Hello VuePress!
# Hello Simple

0 comments on commit 69c85c5

Please sign in to comment.