提交 7bb4d222 编写于 作者: U ULIVZ

Merge branch 'master' into plugin

<a name="0.10.2"></a>
## [0.10.2](https://github.com/vuejs/vuepress/compare/v0.10.1...v0.10.2) (2018-06-20)
### Bug Fixes
* build cannot exit (close: [#580](https://github.com/vuejs/vuepress/issues/580)) ([fa473a7](https://github.com/vuejs/vuepress/commit/fa473a7))
* duplicate description meta (close: [#565](https://github.com/vuejs/vuepress/issues/565)) ([de35315](https://github.com/vuejs/vuepress/commit/de35315))
* edit page from Bitbucket ([#569](https://github.com/vuejs/vuepress/issues/569)) ([5479d6e](https://github.com/vuejs/vuepress/commit/5479d6e))
* multiple markdown tokens in header text ([#564](https://github.com/vuejs/vuepress/issues/564)) ([ec330f0](https://github.com/vuejs/vuepress/commit/ec330f0))
* setting HMR port (close: [#582](https://github.com/vuejs/vuepress/issues/582)) ([#586](https://github.com/vuejs/vuepress/issues/586)) ([64bb80d](https://github.com/vuejs/vuepress/commit/64bb80d))
### Features
* refine Badge's API ([d68199d](https://github.com/vuejs/vuepress/commit/d68199d))
<a name="0.10.1"></a>
## [0.10.1](https://github.com/vuejs/vuepress/compare/v0.10.0...v0.10.1) (2018-06-08)
......
......@@ -87,7 +87,8 @@ Contributions are welcome!
``` bash
yarn
yarn dev # serves VuePress' own docs with itself
yarn dev # serves VuePress' own docs with itself
yarn test # make sure your code change pass the test
```
## License
......
......@@ -104,6 +104,7 @@ function wrapCommand (fn) {
return (...args) => {
return fn(...args).catch(err => {
console.error(chalk.red(err.stack))
process.exitCode = 1
})
}
}
<template>
<p class="bit-sponsor">
<a href="https://www.bitsrc.io/?utm_source=vue&utm_medium=vue&utm_campaign=vue&utm_term=vue&utm_content=vue" target="_blank">
<span>This project is sponsored by</span>
<img alt="bit" src="https://raw.githubusercontent.com/vuejs/vuejs.org/master/themes/vue/source/images/bit.png">
</a>
</p>
</template>
<style lang="stylus">
.bit-sponsor
font-weight 600
background-color #f3f6f8
padding 0.6em 1.2em
border-radius 8px
display inline-block
margin 1em 0 !important
a
color #999
img
height 40px
margin-left 15px
img, span
vertical-align middle
</style>
......@@ -58,6 +58,10 @@ module.exports = {
{
text: 'Default Theme Config',
link: '/default-theme-config/'
},
{
text: 'Changelog',
link: 'https://github.com/vuejs/vuepress/blob/master/CHANGELOG.md'
}
],
sidebar: {
......@@ -81,6 +85,10 @@ module.exports = {
{
text: '默认主题',
link: '/zh/default-theme-config/'
},
{
text: 'Changelog',
link: 'https://github.com/vuejs/vuepress/blob/master/CHANGELOG.md'
}
],
sidebar: {
......
......@@ -3,16 +3,28 @@ home: true
heroImage: /hero.png
actionText: Get Started →
actionLink: /guide/
features:
- title: Simplicity First
details: Minimal setup with markdown-centered project structure helps you focus on writing.
- title: Vue-Powered
details: Enjoy the dev experience of Vue + webpack, use Vue components in markdown, and develop custom themes with Vue.
- title: Performant
details: VuePress generates pre-rendered static HTML for each page, and runs as an SPA once a page is loaded.
footer: MIT Licensed | Copyright © 2018-present Evan You
---
<div style="text-align: center">
<Bit/>
</div>
<div class="features">
<div class="feature">
<h2>Simplicity First</h2>
<p>Minimal setup with markdown-centered project structure helps you focus on writing.</p>
</div>
<div class="feature">
<h2>Vue-Powered</h2>
<p>Enjoy the dev experience of Vue + webpack, use Vue components in markdown, and develop custom themes with Vue.</p>
</div>
<div class="feature">
<h2>Performant</h2>
<p>VuePress generates pre-rendered static HTML for each page, and runs as an SPA once a page is loaded.</p>
</div>
</div>
### As Easy as 1, 2, 3
``` bash
......
......@@ -4,6 +4,8 @@ sidebar: auto
# Config Reference
<Bit/>
## Basic Config
### base
......
......@@ -4,6 +4,8 @@ sidebar: auto
# Default Theme Config
<Bit/>
::: tip
All options listed on this page apply to the default theme only. If you are using a custom theme, the options may be different.
:::
......@@ -142,6 +144,18 @@ sidebarDepth: 2
---
```
### Displaying Header Links of All Pages <Badge text="0.11.0+"/>
The sidebar only displays links for headers in the current active page. You can display all header links for every page with `themeConfig.displayAllHeaders: true`:
``` js
module.exports = {
themeConfig: {
displayAllHeaders: true // Default: false
}
}
```
### Active Header Links
By default, the nested header links and the hash in the URL are updated as the user scrolls to view the different sections of the page. This behavior can be disabled with the following theme config:
......@@ -154,7 +168,7 @@ module.exports = {
}
```
::: tip
::: tip
It is worth mentioning that when you disable this option, the corresponding script of this functionality will not be loaded. This is a small point in our performance optimization.
:::
......
# Introduction
<Bit/>
VuePress is composed of two parts: a minimalistic static site generator with a Vue-powered theming system, and a default theme optimized for writing technical documentation. It was created to support the documentation needs of Vue's own sub projects.
Each page generated by VuePress has its own pre-rendered static HTML, providing great loading performance and is SEO-friendly. Once the page is loaded, however, Vue takes over the static content and turns it into a full Single-Page Application (SPA). Additional pages are fetched on demand as the user navigates around the site.
......
......@@ -130,7 +130,7 @@ module.exports = {
### 嵌套的标题链接
默认情况下,侧边栏会自动地显示由当前页面标的题(headers)组成的的链接,并按照页面本身的结构进行嵌套,你可以通过 `themeConfig.sidebarDepth` 来修改它的行为。默认的深度是 `1`,它将提取到 `h2` 的标题,设置成 `0` 将会禁用标题(headers)链接,同时,最大的深度为 `2`,它将同时提取 `h2` 和 `h3` 标题。
默认情况下,侧边栏会自动地显示由当前页面的标题(headers)组成的链接,并按照页面本身的结构进行嵌套,你可以通过 `themeConfig.sidebarDepth` 来修改它的行为。默认的深度是 `1`,它将提取到 `h2` 的标题,设置成 `0` 将会禁用标题(headers)链接,同时,最大的深度为 `2`,它将同时提取 `h2` 和 `h3` 标题。
也可以使用 `YAML front matter` 来为某个页面重写此值:
......@@ -140,6 +140,18 @@ sidebarDepth: 2
---
```
### 显示所有页面的标题链接 <Badge text="0.11.0+"/>
默认情况下,侧边栏只会显示由当前活动页面的标题(headers)组成的链接,你可以将 `themeConfig.displayAllHeaders` 设置为 `true` 来显示所有页面的标题链接:
``` js
module.exports = {
themeConfig: {
displayAllHeaders: true // 默认值:false
}
}
```
### 活动的标题链接
默认情况下,当用户通过滚动查看页面的不同部分时,嵌套的标题链接和 URL 中的 Hash 值会实时更新,这个行为可以通过以下的配置来禁用:
......
......@@ -54,6 +54,7 @@ export default {
@import './styles/config.styl'
.dropdown-wrapper
cursor pointer
.dropdown-title
display block
&:hover
......
......@@ -108,7 +108,6 @@ export default {
&:hover, &.router-link-active
color $accentColor
.nav-item
cursor pointer
position relative
display inline-block
margin-left 1.5rem
......
<template>
<div class="page">
<slot name="top"/>
<Content :custom="false"/>
<div class="page-edit">
<div class="edit-link" v-if="editLink">
......
......@@ -18,9 +18,10 @@ export default {
? $page.frontmatter.sidebarDepth
: $site.themeConfig.sidebarDepth
const maxDepth = configDepth == null ? 1 : configDepth
const displayAllHeaders = !!$site.themeConfig.displayAllHeaders
if (item.type === 'auto') {
return [link, renderChildren(h, item.children, item.basePath, $route, maxDepth)]
} else if (active && item.headers && !hashRE.test(item.path)) {
} else if ((active || displayAllHeaders) && item.headers && !hashRE.test(item.path)) {
const children = groupHeaders(item.headers)
return [link, renderChildren(h, children, item.path, $route, maxDepth)]
} else {
......@@ -48,7 +49,7 @@ function renderChildren (h, children, path, route, maxDepth, depth = 1) {
return h('ul', { class: 'sidebar-sub-headers' }, children.map(c => {
const active = isActive(route, path + '#' + c.slug)
return h('li', { class: 'sidebar-sub-header' }, [
renderLink(h, '#' + c.slug, c.title, active),
renderLink(h, path + '#' + c.slug, c.title, active),
renderChildren(h, c.children, path, route, maxDepth, depth + 1)
])
}))
......
......@@ -14,7 +14,8 @@
line-height 1.4
padding 1.25rem 1.5rem
margin 0.85rem 0
background transparent
background-color $codeBgColor
border-radius 6px
overflow auto
code
color #fff
......@@ -36,7 +37,8 @@ div[class*="language-"]
line-height 1.4
.highlighted
background-color rgba(0, 0, 0, 66%)
pre
pre, pre[class*="language-"]
background transparent
position relative
z-index 1
&::before
......
......@@ -4,7 +4,7 @@ export const endingSlashRE = /\/$/
export const outboundRE = /^(https?:|mailto:|tel:)/
export function normalize (path) {
return path
return decodeURI(path)
.replace(hashRE, '')
.replace(extRE, '')
}
......
......@@ -103,7 +103,7 @@ module.exports = async function dev (sourceDir, cliOptions = {}) {
host,
dev: { logLevel: 'warn' },
hot: {
port: parseInt(port) + 1,
port: port + 1,
logLevel: 'error'
},
logLevel: 'error',
......@@ -148,7 +148,7 @@ function resolveHost (host) {
async function resolvePort (port) {
const portfinder = require('portfinder')
portfinder.basePort = port || 8080
portfinder.basePort = parseInt(port) || 8080
port = await portfinder.getPortPromise()
return port
}
......@@ -13,12 +13,12 @@ const unescapeHtml = html => String(html)
.replace(/&gt;/g, '>')
const removeMarkdownToken = str => String(str)
.replace(/\[(.*)\]\(.*\)/, '$1') // []()
.replace(/(`|\*\*|\*|_)(.*[^\\])\1/, '$2') // `{t}` | *{t}* | **{t}** | _{t}_
.replace(/(\\)(\*|_|`)/g, '$2') // remove escape char '\'
.replace(/\[(.*)\]\(.*\)/, '$1') // []()
.replace(/(`|\*{1,3}|_)(.*?[^\\])\1/g, '$2') // `{t}` | *{t}* | **{t}** | ***{t}*** | _{t}_
.replace(/(\\)(\*|_|`)/g, '$2') // remove escape char '\'
exports.removeTailHtml = (str) => {
return String(str).replace(/<.*>\s*$/g, '')
return String(str).replace(/\s*?<.*>\s*$/g, '')
}
// only remove some md tokens.
......
{
"name": "vuepress",
"version": "0.10.1",
"version": "0.10.2",
"description": "Minimalistic doc generator with Vue component based layout system",
"main": "lib/index.js",
"bin": {
......
import Content from '@/app/Content.js'
import Content from '@/app/components/Content'
import { mount } from '@vue/test-utils'
import { getRouter, modeTestRunner } from '../util'
......
import {
parseHeaders,
removeTailHtml
} from '@/util/parseHeaders'
describe('parseHeaders', () => {
test('should unescape html', () => {
const input = '&lt;div&gt;'
expect(parseHeaders(input)).toBe('<div>')
})
test('should remove markdown tokens correctly', () => {
const asserts = {
// #238
'[vue](vuejs.org)': 'vue',
'`vue`': 'vue',
'*vue*': 'vue',
'**vue**': 'vue',
'***vue***': 'vue',
'_vue_': 'vue',
'\\_vue\\_': '_vue_',
'\\*vue\\*': '*vue*',
// #564 For multiple markdown tokens
'`a` and `b`': 'a and b',
'***bold and italic***': 'bold and italic',
'**bold** and *italic*': 'bold and italic'
}
Object.keys(asserts).forEach(input => {
expect(parseHeaders(input)).toBe(asserts[input])
})
})
test('should remove tail html correctly', () => {
expect(removeTailHtml('# H1 <div></div>>')).toBe('# H1')
})
})
......@@ -15,10 +15,10 @@
"@babel/highlight" "7.0.0-beta.47"
"@babel/code-frame@^7.0.0-beta.35":
version "7.0.0-beta.49"
resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.0.0-beta.49.tgz#becd805482734440c9d137e46d77340e64d7f51b"
version "7.0.0-beta.51"
resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.0.0-beta.51.tgz#bd71d9b192af978df915829d39d4094456439a0c"
dependencies:
"@babel/highlight" "7.0.0-beta.49"
"@babel/highlight" "7.0.0-beta.51"
"@babel/core@7.0.0-beta.47":
version "7.0.0-beta.47"
......@@ -242,9 +242,9 @@
esutils "^2.0.2"
js-tokens "^3.0.0"
"@babel/highlight@7.0.0-beta.49":
version "7.0.0-beta.49"
resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.0.0-beta.49.tgz#96bdc6b43e13482012ba6691b1018492d39622cc"
"@babel/highlight@7.0.0-beta.51":
version "7.0.0-beta.51"
resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.0.0-beta.51.tgz#e8844ae25a1595ccfd42b89623b4376ca06d225d"
dependencies:
chalk "^2.0.0"
esutils "^2.0.2"
......@@ -801,8 +801,8 @@
vue-template-es2015-compiler "^1.6.0"
"@vue/test-utils@^1.0.0-beta.16":
version "1.0.0-beta.18"
resolved "https://registry.yarnpkg.com/@vue/test-utils/-/test-utils-1.0.0-beta.18.tgz#53c22c4b90211a98dbf2708c0b717c18adaa993c"
version "1.0.0-beta.19"
resolved "https://registry.yarnpkg.com/@vue/test-utils/-/test-utils-1.0.0-beta.19.tgz#a1ec452081f6c7a9fa245478e2de227953a30455"
dependencies:
lodash "^4.17.4"
......@@ -1011,8 +1011,8 @@ acorn@^3.0.4:
resolved "https://registry.yarnpkg.com/acorn/-/acorn-3.3.0.tgz#45e37fb39e8da3f25baee3ff5369e2bb5f22017a"
acorn@^5.0.0, acorn@^5.3.0, acorn@^5.5.0, acorn@^5.6.2:
version "5.6.2"
resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.6.2.tgz#b1da1d7be2ac1b4a327fb9eab851702c5045b4e7"
version "5.7.1"
resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.7.1.tgz#f095829297706a7c9776958c0afc8930a9b9d9d8"
add-stream@^1.0.0:
version "1.0.0"
......@@ -1049,8 +1049,8 @@ ajv@^6.0.1, ajv@^6.1.0:
uri-js "^4.2.1"
algoliasearch@^3.24.5:
version "3.27.1"
resolved "https://registry.yarnpkg.com/algoliasearch/-/algoliasearch-3.27.1.tgz#e1af42b97dbf44a2dd3a8c907be99c0c34e48414"
version "3.28.0"
resolved "https://registry.yarnpkg.com/algoliasearch/-/algoliasearch-3.28.0.tgz#12b6c8bda397eba805a7ff998ac87f6988411d2d"
dependencies:
agentkeepalive "^2.2.0"
debug "^2.6.8"
......@@ -1824,12 +1824,12 @@ caniuse-api@^1.5.2:
lodash.uniq "^4.5.0"
caniuse-db@^1.0.30000529, caniuse-db@^1.0.30000634, caniuse-db@^1.0.30000639:
version "1.0.30000852"
resolved "https://registry.yarnpkg.com/caniuse-db/-/caniuse-db-1.0.30000852.tgz#c37a706048f8d81f87946a7c13f39ed636876659"
version "1.0.30000856"
resolved "https://registry.yarnpkg.com/caniuse-db/-/caniuse-db-1.0.30000856.tgz#fbebb99abe15a5654fc7747ebb5315bdfde3358f"
caniuse-lite@^1.0.30000844, caniuse-lite@^1.0.30000851:
version "1.0.30000852"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30000852.tgz#8b7510cec030cac7842e52beca2bf292af65f935"
version "1.0.30000856"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30000856.tgz#ecc16978135a6f219b138991eb62009d25ee8daa"
capture-exit@^1.2.0:
version "1.2.0"
......@@ -5365,8 +5365,8 @@ markdown-it-emoji@^1.4.0:
resolved "https://registry.yarnpkg.com/markdown-it-emoji/-/markdown-it-emoji-1.4.0.tgz#9bee0e9a990a963ba96df6980c4fddb05dfb4dcc"
markdown-it-table-of-contents@^0.3.3:
version "0.3.3"
resolved "https://registry.yarnpkg.com/markdown-it-table-of-contents/-/markdown-it-table-of-contents-0.3.3.tgz#b62e943c32de2c4a27d3e7c83cd63acbc2a9c4a2"
version "0.3.6"
resolved "https://registry.yarnpkg.com/markdown-it-table-of-contents/-/markdown-it-table-of-contents-0.3.6.tgz#2a733c52485cd47769365402681987ed7d9e64a9"
dependencies:
lodash.assign "~4.2.0"
string "~3.3.3"
......@@ -6622,8 +6622,8 @@ pretty@2.0.0:
js-beautify "^1.6.12"
prismjs@^1.13.0:
version "1.14.0"
resolved "https://registry.yarnpkg.com/prismjs/-/prismjs-1.14.0.tgz#bbccfdb8be5d850d26453933cb50122ca0362ae0"
version "1.15.0"
resolved "https://registry.yarnpkg.com/prismjs/-/prismjs-1.15.0.tgz#8801d332e472091ba8def94976c8877ad60398d9"
optionalDependencies:
clipboard "^2.0.0"
......@@ -6664,8 +6664,8 @@ pseudomap@^1.0.1, pseudomap@^1.0.2:
resolved "https://registry.yarnpkg.com/pseudomap/-/pseudomap-1.0.2.tgz#f052a28da70e618917ef0a8ac34c1ae5a68286b3"
psl@^1.1.24:
version "1.1.27"
resolved "https://registry.yarnpkg.com/psl/-/psl-1.1.27.tgz#2b2c77019db86855170d903532400bf71ee085b6"
version "1.1.28"
resolved "https://registry.yarnpkg.com/psl/-/psl-1.1.28.tgz#4fb6ceb08a1e2214d4fd4de0ca22dae13740bc7b"
public-encrypt@^4.0.0:
version "4.0.2"
......@@ -7082,8 +7082,8 @@ resolve@1.1.7:
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.1.7.tgz#203114d82ad2c5ed9e8e0411b3932875e889e97b"
resolve@^1.2.0, resolve@^1.3.2, resolve@^1.6.0:
version "1.7.1"
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.7.1.tgz#aadd656374fd298aee895bc026b8297418677fd3"
version "1.8.0"
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.8.0.tgz#a7f2ac27b78480ecc09c83782741d9f26e4f0c3e"
dependencies:
path-parse "^1.0.5"
......@@ -8345,8 +8345,8 @@ webpack-log@^1.0.1, webpack-log@^1.1.1, webpack-log@^1.1.2:
uuid "^3.1.0"
webpack-merge@^4.1.2:
version "4.1.2"
resolved "https://registry.yarnpkg.com/webpack-merge/-/webpack-merge-4.1.2.tgz#5d372dddd3e1e5f8874f5bf5a8e929db09feb216"
version "4.1.3"
resolved "https://registry.yarnpkg.com/webpack-merge/-/webpack-merge-4.1.3.tgz#8aaff2108a19c29849bc9ad2a7fd7fce68e87c4a"
dependencies:
lodash "^4.17.5"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册