Skip to content

Commit f30264d

Browse files
committed
Merge branch 'master' of https://github.com/vuejs/vuepress into explode-md-includes
2 parents 61ac480 + 5e87b65 commit f30264d

26 files changed

+298
-139
lines changed

README.md

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
<p align="center">
22
<a href="https://vuepress.vuejs.org/" target="_blank">
3-
<img width="280" src="https://github.com/vuejs/vuepress/blob/master/docs/.vuepress/public/hero.png" alt="logo">
3+
<img width="280" src="https://raw.githubusercontent.com/vuejs/vuepress/master/docs/.vuepress/public/hero.png" alt="logo">
44
</a>
55
</p>
66

7+
<p align="center">
8+
<a href="https://npmcharts.com/compare/vuepress?minimal=true"><img src="https://img.shields.io/npm/dm/vuepress.svg" alt="Downloads"></a>
9+
<a href="https://www.npmjs.com/package/vuepress"><img src="https://img.shields.io/npm/v/vuepress.svg" alt="Version"></a>
10+
<a href="https://www.npmjs.com/package/vuepress"><img src="https://img.shields.io/npm/l/vuepress.svg" alt="License"></a>
11+
</p>
12+
713
# VuePress
814

915
> Minimalistic docs generator with Vue component based layout system
@@ -15,13 +21,14 @@ https://vuepress.vuejs.org/
1521
- [Built-in markdown extensions](https://vuepress.vuejs.org/guide/markdown.html) optimized for technical documentation
1622
- [Ability to leverage Vue inside markdown files](https://vuepress.vuejs.org/guide/using-vue.html)
1723
- [Vue-powered custom theme system](https://vuepress.vuejs.org/guide/custom-themes.html)
18-
- Service Worker Integration
19-
- Google Analytics Integration
20-
- Multi-Language Support
24+
- [Service Worker Integration](https://vuepress.vuejs.org/config/#serviceworker)
25+
- [Google Analytics Integration](https://vuepress.vuejs.org/config/#ga)
26+
- [Multi-Language Support](https://vuepress.vuejs.org/guide/i18n.html)
2127
- A default theme with:
2228
- Responsive layout
2329
- Optional Homepage
24-
- Automatic basic typeahead search
30+
- [Automatic basic typeahead search](https://vuepress.vuejs.org/default-theme-config/#built-in-search)
31+
- [Algolia Search](https://vuepress.vuejs.org/default-theme-config/#algolia-search)
2532
- Customizable navbar and sidebar
2633
- Auto-generated GitHub link and page edit links
2734

@@ -44,4 +51,4 @@ yarn dev # serves VuePress' own docs with itself
4451

4552
## License
4653

47-
MIT
54+
[MIT](https://github.com/vuejs/vuepress/blob/master/LICENSE)

docs/default-theme-config/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,14 @@ module.exports = {
321321
}
322322
```
323323

324+
You can also hide the edit link on a specific page via `YAML front matter`:
325+
326+
``` yaml
327+
---
328+
editLink: false
329+
---
330+
```
331+
324332
## Simple CSS Override
325333

326334
If you wish to apply simple overrides to the styling of the default theme, you can create an `.vuepress/override.styl` file. This is a [Stylus](http://stylus-lang.com/) file but you can use normal CSS syntax as well.

docs/guide/custom-themes.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ This is the value of `$site` of this very website:
2828
"base": "/",
2929
"pages": [
3030
{
31+
"lastModified": 1524027677,
3132
"path": "/",
3233
"title": "VuePress",
3334
"frontmatter": {}
@@ -43,7 +44,8 @@ This is the `$page` object for this page you are looking at:
4344

4445
``` json
4546
{
46-
"path": "/custom-themes.html",
47+
"lastModified": 1524847549,
48+
"path": "/guide/custom-themes.html",
4749
"title": "Custom Themes",
4850
"headers": [/* ... */],
4951
"frontmatter": {}
@@ -54,6 +56,10 @@ If the user provided `themeConfig` in `.vuepress/config.js`, it will also be ava
5456

5557
Finally, don't forget that `this.$route` and `this.$router` are also available as part of Vue Router's API.
5658

59+
::: tip
60+
`lastModified` is the UNIX timestamp of this file's last git commit, so please ensure you have git installed.
61+
:::
62+
5763
## Content Excerpt
5864

5965
If a markdown file contains a `<!-- more -->` comment, any content above the comment will be extracted and exposed as `$page.excerpt`. If you are building custom theme for blogging, this data can be used to render a post list with excerpts.

docs/guide/deploy.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ The following guides are based on a few shared assumptions:
2020

2121
If you are deploying to `https://<USERNAME>.github.io/`, you can omit `base` as it defaults to `"/"`.
2222

23-
If your are deploying to `https://<USERNAME>.github.io/<REPO>/`, (i.e. your repository is at `https://github.com/<USERNAME>/REPO>`), set `base` to `"/<REPO>/"`.
23+
If your are deploying to `https://<USERNAME>.github.io/<REPO>/`, (i.e. your repository is at `https://github.com/<USERNAME>/<REPO>`), set `base` to `"/<REPO>/"`.
2424

2525
2. Inside your project, create `deploy.sh` with the following content (with highlighted lines uncommented appropriately) and run it to deploy:
2626

@@ -62,7 +62,7 @@ You can also run the above script in your CI setup to enable automatic deploymen
6262

6363
If you are deploying to `https://<USERNAME or GROUP>.gitlab.io/`, you can omit `base` as it defaults to `"/"`.
6464

65-
If your are deploying to `https://<USERNAME or GROUP>.gitlab.io/<REPO>/`, (i.e. your repository is at `https://gitlab.com/<USERNAME>/REPO>`), set `base` to `"/<REPO>/"`.
65+
If your are deploying to `https://<USERNAME or GROUP>.gitlab.io/<REPO>/`, (i.e. your repository is at `https://gitlab.com/<USERNAME>/<REPO>`), set `base` to `"/<REPO>/"`.
6666

6767
2. Set `dest` in `.vuepress/config.js` to `public`.
6868

docs/guide/using-vue.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ Make sure a custom component's name either contains a hyphen or is in PascalCase
128128

129129
### Using Pre-processors
130130

131-
VuePress has built-in webpack config for the following pre-processors: `sass`, `scss`, `less`, `stylus` and `pug`. All you need to do is installing the corresposnding dependencies. For example, to enable `sass`, install the following in your project:
131+
VuePress has built-in webpack config for the following pre-processors: `sass`, `scss`, `less`, `stylus` and `pug`. All you need to do is installing the corresponding dependencies. For example, to enable `sass`, install the following in your project:
132132

133133
``` bash
134134
yarn add -D sass-loader node-sass

docs/zh/default-theme-config/README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ module.exports = {
5252
}
5353
```
5454

55-
当你提供了一个 `items` 数组而不是一个单一的 `link` 时,它将会显示以 `下拉列表` 的方式显示
55+
当你提供了一个 `items` 数组而不是一个单一的 `link` 时,它将显示为一个 `下拉列表`
5656

5757
```js
5858
module.exports = {
@@ -317,6 +317,14 @@ module.exports = {
317317
}
318318
```
319319

320+
你可以通过 `YAML front matter` 来禁用指定页面的编辑链接:
321+
322+
``` yaml
323+
---
324+
editLink: false
325+
---
326+
```
327+
320328
## 简单的 CSS 覆盖
321329

322330
如果你只是希望应用一些简单的 overrides 到默认主题的样式上,你可以创建一个 `.vuepress/override.styl` 文件,这是一个 [Stylus](http://stylus-lang.com/) 文件,但是你仍然可以使用普通的 CSS 语法。

docs/zh/guide/custom-themes.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ VuePress 使用单文件组件来构建自定义主题。想要开发一个自
2828
"base": "/",
2929
"pages": [
3030
{
31+
"lastModified": 1524027677,
3132
"path": "/",
3233
"title": "VuePress",
3334
"frontmatter": {}
@@ -43,6 +44,7 @@ VuePress 使用单文件组件来构建自定义主题。想要开发一个自
4344

4445
``` json
4546
{
47+
"lastModified": 1524847549,
4648
"path": "/custom-themes.html",
4749
"title": "自定义主题",
4850
"headers": [/* ... */],
@@ -54,6 +56,10 @@ VuePress 使用单文件组件来构建自定义主题。想要开发一个自
5456

5557
最后,别忘了,作为 Vue Router API 的一部分,`this.$route``this.$router` 同样可以使用。
5658

59+
::: tip 提示
60+
`lastModified` 是这个文件最后一次 git 提交的 unix 时间戳,所以请确保你已经安装了 git。
61+
:::
62+
5763
## 内容摘抄
5864

5965
如果一个 markdown 文件中有一个 `<!-- more -->` 注释,则该注释之前的内容会被抓取并暴露在 `$page.excerpt` 属性中。如果你在开发一个博客主题,你可以用这个属性来渲染一个带摘抄的文章列表。

docs/zh/guide/deploy.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
如果你打算发布到 `https://<USERNAME>.github.io/`,则可以省略这一步,因为 `base` 默认即是 `"/"`
2222

23-
如果你打算发布到 `https://<USERNAME>.github.io/<REPO>/`(也就是说你的仓库在 `https://github.com/<USERNAME>/REPO>`),则将 `base` 设置为 `"/<REPO>/"`
23+
如果你打算发布到 `https://<USERNAME>.github.io/<REPO>/`(也就是说你的仓库在 `https://github.com/<USERNAME>/<REPO>`),则将 `base` 设置为 `"/<REPO>/"`
2424

2525
2. 在你的项目中,创建一个如下的 `deploy.sh` 文件(请自行判断去掉高亮行的注释):
2626

@@ -62,7 +62,7 @@ cd -
6262

6363
如果你打算发布到 `https://<USERNAME or GROUP>.gitlab.io/`,则可以省略这一步,因为 `base` 默认即是 `"/"`
6464

65-
如果你打算发布到 `https://<USERNAME or GROUP>.gitlab.io/<REPO>/`(也就是说你的仓库在 `https://gitlab.com/<USERNAME>/REPO>`),则将 `base` 设置为 `"/<REPO>/"`
65+
如果你打算发布到 `https://<USERNAME or GROUP>.gitlab.io/<REPO>/`(也就是说你的仓库在 `https://gitlab.com/<USERNAME>/<REPO>`),则将 `base` 设置为 `"/<REPO>/"`
6666

6767
2.`.vuepress/config.js` 中将 `dest` 设置为 `public`
6868
3. 在你项目的根目录下创建一个名为 `.gitlab-ci.yml` 的文件,无论何时你提交了更改,它都会帮助你自动构建和部署:

lib/app/app.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import Router from 'vue-router'
33
import Content from './Content'
44
import ClientOnly from './ClientOnly'
55
import dataMixin from './dataMixin'
6-
import NotFound from '@notFound'
6+
import store from './store'
77
import { routes } from '@temp/routes'
88
import { siteData } from '@temp/siteData'
99
import enhanceApp from '@temp/enhanceApp'
@@ -41,12 +41,6 @@ Vue.prototype.$withBase = function (path) {
4141
}
4242
}
4343

44-
// add 404 route
45-
routes.push({
46-
path: '*',
47-
component: NotFound
48-
})
49-
5044
export function createApp () {
5145
const router = new Router({
5246
base: siteData.base,
@@ -57,7 +51,12 @@ export function createApp () {
5751
if (saved) {
5852
return saved
5953
} else if (to.hash) {
60-
return false
54+
if (store.disableScrollBehavior) {
55+
return false
56+
}
57+
return {
58+
selector: to.hash
59+
}
6160
} else {
6261
return { x: 0, y: 0 }
6362
}

lib/app/store.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// It is not yet time to use Vuex to manage the global state
2+
// singleton object as a global store.
3+
const state = {
4+
disableScrollBehavior: false
5+
}
6+
7+
export default state

lib/build.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ module.exports = async function build (sourceDir, cliOptions = {}) {
2121
}
2222

2323
const { outDir } = options
24+
if (path.resolve() === outDir) {
25+
return console.error(chalk.red('Unexpected option: outDir cannot be set to the current working directory.\n'))
26+
}
2427
await fs.remove(outDir)
2528

2629
let clientConfig = createClientConfig(options, cliOptions).toConfig()
@@ -103,6 +106,11 @@ module.exports = async function build (sourceDir, cliOptions = {}) {
103106
reject(new Error(`Failed to compile with errors.`))
104107
return
105108
}
109+
if (cliOptions.debug && stats.hasWarnings()) {
110+
stats.toJson().warnings.forEach(warning => {
111+
console.warn(warning)
112+
})
113+
}
106114
resolve(stats.toJson({ modules: false }))
107115
})
108116
})

lib/default-theme/Layout.vue

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import Navbar from './Navbar.vue'
2828
import Page from './Page.vue'
2929
import Sidebar from './Sidebar.vue'
3030
import { pathToComponentName } from '@app/util'
31+
import store from '@app/store'
3132
import { resolveSidebarItems } from './util'
3233
import throttle from 'lodash.throttle'
3334
@@ -165,7 +166,7 @@ export default {
165166
const sidebarLinks = [].slice.call(document.querySelectorAll('.sidebar-link'))
166167
const anchors = [].slice.call(document.querySelectorAll('.header-anchor'))
167168
.filter(anchor => sidebarLinks.some(sidebarLink => sidebarLink.hash === anchor.hash))
168-
169+
169170
const scrollTop = Math.max(window.pageYOffset, document.documentElement.scrollTop, document.body.scrollTop)
170171
171172
for (let i = 0; i < anchors.length; i++) {
@@ -177,7 +178,13 @@ export default {
177178
(!nextAnchor || scrollTop < nextAnchor.parentElement.offsetTop - 10))
178179
179180
if (isActive && this.$route.hash !== anchor.hash) {
180-
this.$router.replace(anchor.hash)
181+
store.disableScrollBehavior = true
182+
this.$router.replace(anchor.hash, () => {
183+
// execute after scrollBehavior handler.
184+
this.$nextTick(() => {
185+
store.disableScrollBehavior = false
186+
})
187+
})
181188
return
182189
}
183190
}

lib/default-theme/NavLink.vue

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
v-else
1010
:href="link"
1111
class="nav-link"
12-
:target="isMailto(link) ? null : '_blank'"
13-
:rel="isMailto(link) ? null : 'noopener noreferrer'"
12+
:target="isMailto(link) || isTel(link) ? null : '_blank'"
13+
:rel="isMailto(link) || isTel(link) ? null : 'noopener noreferrer'"
1414
>{{ item.text }}</a>
1515
</template>
1616

1717
<script>
18-
import { isExternal, isMailto, ensureExt } from './util'
18+
import { isExternal, isMailto, isTel, ensureExt } from './util'
1919
2020
export default {
2121
props: {
@@ -30,7 +30,8 @@ export default {
3030
},
3131
methods: {
3232
isExternal,
33-
isMailto
33+
isMailto,
34+
isTel
3435
}
3536
}
3637
</script>

lib/default-theme/NavLinks.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export default {
109109
&:hover, &.router-link-active
110110
color $accentColor
111111
.nav-item
112-
cursor: pointer
112+
cursor pointer
113113
position relative
114114
display inline-block
115115
margin-left 1.5rem

lib/default-theme/Page.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ export default {
5252
}
5353
},
5454
editLink () {
55+
if (this.$page.frontmatter.editLink === false) {
56+
return
57+
}
5558
const {
5659
repo,
5760
editLinks,

lib/default-theme/styles/code.styl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
border-radius 6px
1717
padding 1.25rem 1.5rem
1818
margin 0.85rem 0
19-
white-space pre-wrap
20-
word-break break-word
2119
overflow auto
2220
position relative
2321
code

lib/default-theme/styles/mobile.styl

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,13 @@ $mobileSidebarWidth = $sidebarWidth * 0.82
2121
transition transform .2s ease
2222
.page
2323
padding-left 0
24-
.theme-container.sidebar-open
25-
.sidebar
26-
transform translateX(0)
24+
.theme-container
25+
&.sidebar-open
26+
.sidebar
27+
transform translateX(0)
28+
&.no-navbar
29+
.sidebar
30+
padding-top: 0
2731

2832
// narrow mobile
2933
@media (max-width: $MQMobileNarrow)

lib/default-theme/styles/theme.styl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,14 @@ th, td
167167
.sidebar-mask
168168
display: block
169169
&.no-navbar
170-
.content:not(.custom)
170+
.content:not(.custom) >
171171
h1, h2, h3, h4, h5, h6
172172
margin-top 1.5rem
173173
padding-top 0
174+
.sidebar
175+
top 0
176+
.custom-layout
177+
padding-top 0
174178

175179

176180
@media (min-width: ($MQMobile + 1px))

lib/default-theme/util.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export const hashRE = /#.*$/
22
export const extRE = /\.(md|html)$/
33
export const endingSlashRE = /\/$/
4-
export const outboundRE = /^(https?:|mailto:)/
4+
export const outboundRE = /^(https?:|mailto:|tel:)/
55

66
export function normalize (path) {
77
return path
@@ -24,6 +24,10 @@ export function isMailto (path) {
2424
return /^mailto:/.test(path)
2525
}
2626

27+
export function isTel (path) {
28+
return /^tel:/.test(path)
29+
}
30+
2731
export function ensureExt (path) {
2832
if (isExternal(path)) {
2933
return path

lib/markdown/highlight.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ module.exports = (str, lang) => {
1717
if (!lang) {
1818
return wrap(str, 'text')
1919
}
20+
lang = lang.toLowerCase()
2021
const rawLang = lang
2122
if (lang === 'vue' || lang === 'html') {
2223
lang = 'markup'

0 commit comments

Comments
 (0)