Skip to content

Commit ea6e17f

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents fb778e4 + 5f1eb0e commit ea6e17f

File tree

94 files changed

+909
-507
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+909
-507
lines changed

.eslintrc.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ module.exports = {
66
],
77
rules: {
88
indent: ['error', 2, { MemberExpression: 'off' }],
9-
"no-undef": ["error"]
9+
"no-undef": ["error"],
10+
'operator-linebreak': ["error", "before"]
1011
}
1112
}

CHANGELOG.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,53 @@
1+
2+
<a name="1.0.0-alpha.37"></a>
3+
# [1.0.0-alpha.37](https://github.com/vuejs/vuepress/compare/v1.0.0-alpha.36...v1.0.0-alpha.37) (2019-02-08)
4+
5+
6+
### Features
7+
8+
* **$core:** redirects for clean urls ([#1269](https://github.com/vuejs/vuepress/issues/1269)) ([213bb34](https://github.com/vuejs/vuepress/commit/213bb34))
9+
* **$theme-default:** fallback current group node to page node if children doesn't exist ([11ce576](https://github.com/vuejs/vuepress/commit/11ce576))
10+
* **$theme-default:** highlight sidebar link text at root level like sidebar group heading text ([05e793f](https://github.com/vuejs/vuepress/commit/05e793f))
11+
* **$theme-default:** unify the text color of sidebar heading text and root-level sidebar link ([3e47a20](https://github.com/vuejs/vuepress/commit/3e47a20))
12+
13+
14+
15+
<a name="1.0.0-alpha.36"></a>
16+
# [1.0.0-alpha.36](https://github.com/vuejs/vuepress/compare/v1.0.0-alpha.35...v1.0.0-alpha.36) (2019-02-03)
17+
18+
19+
### Bug Fixes
20+
21+
* **$core:** SFC page compile error (close: [#1110](https://github.com/vuejs/vuepress/issues/1110)) ([8f5b0cd](https://github.com/vuejs/vuepress/commit/8f5b0cd))
22+
23+
24+
### Features
25+
26+
* **$theme-default:** refine sidebar groups ([#1257](https://github.com/vuejs/vuepress/issues/1257)) ([01dd45b](https://github.com/vuejs/vuepress/commit/01dd45b)), closes [#814](https://github.com/vuejs/vuepress/issues/814) [#783](https://github.com/vuejs/vuepress/issues/783) [#287](https://github.com/vuejs/vuepress/issues/287)
27+
- `sidebarDepth` for a specified sidebar group.
28+
- Nested sidebar groups.
29+
- Clickable heading for sidebar groups.
30+
31+
32+
33+
<a name="1.0.0-alpha.35"></a>
34+
# [1.0.0-alpha.35](https://github.com/vuejs/vuepress/compare/v1.0.0-alpha.34...v1.0.0-alpha.35) (2019-01-30)
35+
36+
37+
### Bug Fixes
38+
39+
* **$core:** bust cache of extra watching files ([075f470](https://github.com/vuejs/vuepress/commit/075f470))
40+
* **$core:** never throw error if layout component does not exist ([#1247](https://github.com/vuejs/vuepress/issues/1247)) ([49c5983](https://github.com/vuejs/vuepress/commit/49c5983))
41+
* **$core:** style and platte path sep on windows ([#1246](https://github.com/vuejs/vuepress/issues/1246)) ([592918a](https://github.com/vuejs/vuepress/commit/592918a))
42+
* **$theme-default:** bitbucket edit link goes to wrong link (close: [#1235](https://github.com/vuejs/vuepress/issues/1235)) ([#1248](https://github.com/vuejs/vuepress/issues/1248)) ([3c5b3a6](https://github.com/vuejs/vuepress/commit/3c5b3a6))
43+
44+
45+
### Features
46+
47+
* **$core:** exclude temp dir from being ignored watching ([c6797dd](https://github.com/vuejs/vuepress/commit/c6797dd))
48+
49+
50+
151
<a name="1.0.0-alpha.34"></a>
252
# [1.0.0-alpha.34](https://github.com/vuejs/vuepress/compare/v1.0.0-alpha.33...v1.0.0-alpha.34) (2019-01-29)
353

README.md

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

@@ -12,7 +12,7 @@
1212
<a href="https://discordapp.com/invite/HBherRA"><img src="https://img.shields.io/badge/Discord-join%20chat-738bd7.svg" alt="vuepress channel on Discord"></a>
1313
</p>
1414

15-
> This is the branch for `VuePress Next`.
15+
> This is the branch for `VuePress Next` and docs are available at https://vuepress.vuejs.org.
1616
1717
## Status: alpha
1818

@@ -22,84 +22,22 @@ For 0.x, it's moved to [0.x branch](https://github.com/vuejs/vuepress/tree/0.x)
2222

2323
> Note that we are working hard to improve the documentation and contributions welcome if you keep up with the latest changes.
2424
25-
# VuePress
26-
27-
> Minimalistic docs generator with Vue component based layout system
28-
29-
https://vuepress.vuejs.org/
30-
3125
## Install
3226

3327
```bash
3428
yarn add vuepress -D # Install 0.x.x.
3529
yarn add vuepress@next -D # Install next.
3630
```
3731

38-
## Features
39-
40-
**Built-in markdown extensions**
41-
42-
* [Table of Contents](https://vuepress.vuejs.org/guide/markdown.html#table-of-contents)
43-
* [Custom Containers](https://vuepress.vuejs.org/guide/markdown.html#custom-containers)
44-
* [Line Highlighting](https://vuepress.vuejs.org/guide/markdown.html#line-highlighting-in-code-blocks)
45-
* [Line Numbers](https://vuepress.vuejs.org/guide/markdown.html#line-numbers)
46-
* [Import Code Snippets](https://vuepress.vuejs.org/guide/markdown.html#import-code-snippets)
47-
48-
**Using Vue in Markdown**
49-
50-
* [Templating](https://vuepress.vuejs.org/guide/using-vue.html#templating)
51-
* [Using Components](https://vuepress.vuejs.org/guide/using-vue.html#using-components)
52-
53-
**Vue-powered custom theme system**
54-
55-
* [Metadata](https://vuepress.vuejs.org/theme/writing-a-theme.html#site-and-page-metadata)
56-
* [Content Excerpt](https://vuepress.vuejs.org/theme/writing-a-theme.html#content-excerpt)
57-
58-
**Default theme**
59-
60-
* Responsive layout
61-
* [Optional Homepage](https://vuepress.vuejs.org/theme/default-theme-config.html#homepage)
62-
* [Simple out-of-the-box header-based search](https://vuepress.vuejs.org/theme/default-theme-config.html#built-in-search)
63-
* [Algolia Search](https://vuepress.vuejs.org/theme/default-theme-config.html#algolia-search)
64-
* Customizable [navbar](https://vuepress.vuejs.org/theme/default-theme-config.html#navbar) and [sidebar](https://vuepress.vuejs.org/theme/default-theme-config.html#sidebar)
65-
* [Auto-generated GitHub link and page edit links](https://vuepress.vuejs.org/theme/default-theme-config.html#git-repo-and-edit-links)
66-
* [PWA: Popup UI to refresh contents](https://vuepress.vuejs.org/theme/default-theme-config.html#popup-ui-to-refresh-contents)
67-
* [Last Updated](https://vuepress.vuejs.org/theme/default-theme-config.html#last-updated)
68-
69-
**Miscellaneous**
70-
71-
* [Multi-Language Support](https://vuepress.vuejs.org/guide/i18n.html)
72-
* [Service Worker](https://vuepress.vuejs.org/config/#serviceworker)
73-
* [Google Analytics](https://vuepress.vuejs.org/config/#ga)
74-
7532
## Showcase
7633

77-
Websites built with VuePress:
78-
79-
**Vue Ecosystem**
80-
81-
* [vue-cli](https://cli.vuejs.org/)
82-
* [vuex](https://vuex.vuejs.org/)
83-
* [vue-server-renderer](https://ssr.vuejs.org/)
84-
* [vue-router](https://router.vuejs.org/)
85-
* [vue-test-utils](https://vue-test-utils.vuejs.org/)
86-
* [vue-loader](https://vue-loader.vuejs.org/)
87-
* [vetur](https://vuejs.github.io/vetur/)
88-
* [rollup-plugin-vue](https://rollup-plugin-vue.vuejs.org/)
89-
90-
**Community**
91-
92-
* [cr-vue](https://cr-vue.mio3io.com/)
93-
* [vuesax](https://lusaxweb.github.io/vuesax/)
94-
* [vuemeetups](https://vuemeetups.org)
95-
34+
Check out [Awesome Vuepress](https://github.com/ulivz/awesome-vuepress) to find awesome things related to VuePress.
9635

9736
## Development
9837

9938
> Please make sure your version of Node.js is greater than 8.
10039
10140
``` bash
102-
yarn
10341
yarn dev # serves VuePress' own docs with itself
10442
yarn test # make sure your code change pass the test
10543
```

lerna.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"lerna": "2.5.1",
33
"npmClient": "yarn",
44
"useWorkspaces": true,
5-
"version": "1.0.0-alpha.34"
5+
"version": "1.0.0-alpha.37"
66
}

packages/@vuepress/core/lib/app/app.js

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import appEnhancers from '@internal/app-enhancers'
88
import globalUIComponents from '@internal/global-ui'
99
import ClientComputedMixin from '@transform/ClientComputedMixin'
1010
import VuePress from './plugins/VuePress'
11+
import { handleRedirectForCleanUrls } from './redirect.js'
1112

1213
// built-in components
1314
import Content from './components/Content.js'
@@ -21,8 +22,8 @@ if (module.hot) {
2122
module.hot.accept(VUEPRESS_TEMP_PATH + '/internal/siteData.js', () => {
2223
if (siteData.base !== prevBase) {
2324
window.alert(
24-
`[vuepress] Site base has changed. ` +
25-
`Please restart dev server to ensure correct asset paths.`
25+
`[vuepress] Site base has changed. `
26+
+ `Please restart dev server to ensure correct asset paths.`
2627
)
2728
}
2829
})
@@ -74,16 +75,7 @@ export function createApp (isServer) {
7475
}
7576
})
7677

77-
// redirect /foo to /foo/
78-
router.beforeEach((to, from, next) => {
79-
if (!/(\/|\.html)$/.test(to.path)) {
80-
next(Object.assign({}, to, {
81-
path: to.path + '/'
82-
}))
83-
} else {
84-
next()
85-
}
86-
})
78+
handleRedirectForCleanUrls(router)
8779

8880
const options = {}
8981

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// In VuePress, we have following convention about routing:
2+
//
3+
// - `/foo/` means source file is `/foo/{README|index}.md`
4+
// - `/foo.html` means your source file is `/foo.md`
5+
//
6+
// The original design of VuePress relied on above two styles
7+
// of routing, especially the calculation involved of routes at
8+
// default theme. so we can't easily modify `/foo.html` directly
9+
// to `/foo` (i.e. remove html suffix)
10+
//
11+
// This "temporary" utility handles redirect of clean urls, with
12+
// this utility, you'll get:
13+
//
14+
// For unknown request `/foo`
15+
// - redirect to `/foo.html` if it exists
16+
// - redirect to `/foo/` if it exists
17+
//
18+
// For unknown request `/foo/`
19+
// - redirect to `/foo.html` if it exists
20+
//
21+
// If all the above redirect rules don't exist, you'll get a 404
22+
23+
export function handleRedirectForCleanUrls (router) {
24+
router.beforeEach((to, from, next) => {
25+
if (isRouteExists(router, to.path)) {
26+
next()
27+
} else {
28+
if (!/(\/|\.html)$/.test(to.path)) {
29+
const endingSlashUrl = to.path + '/'
30+
const endingHtmlUrl = to.path + '.html'
31+
if (isRouteExists(router, endingHtmlUrl)) {
32+
next(endingHtmlUrl)
33+
} else if (isRouteExists(router, endingSlashUrl)) {
34+
next(endingSlashUrl)
35+
} else {
36+
next()
37+
}
38+
} else if (/\/$/.test(to.path)) {
39+
const endingHtmlUrl = to.path.replace(/\/$/, '') + '.html'
40+
if (isRouteExists(router, endingHtmlUrl)) {
41+
next(endingHtmlUrl)
42+
} else {
43+
next()
44+
}
45+
} else {
46+
next()
47+
}
48+
}
49+
})
50+
}
51+
52+
function isRouteExists (router, path) {
53+
return router.options.routes.filter(route => route.path === path).length > 0
54+
}

packages/@vuepress/core/lib/dev.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,12 @@ async function prepareServer (sourceDir, cliOptions = {}, context) {
3737
}
3838

3939
// Curry update handler by update type
40-
const spawnUpdate = (updateType) =>
41-
file => update(`${chalk.red(updateType)} ${chalk.cyan(file)}`)
40+
const spawnUpdate = updateType => file => {
41+
const target = path.join(sourceDir, file)
42+
// Bust cache.
43+
delete require.cache[target]
44+
update(`${chalk.red(updateType)} ${chalk.cyan(file)}`)
45+
}
4246

4347
// watch add/remove of files
4448
const pagesWatcher = chokidar.watch([
@@ -97,8 +101,8 @@ async function prepareServer (sourceDir, cliOptions = {}, context) {
97101
const { host, displayHost } = await resolveHost(cliOptions.host || ctx.siteConfig.host)
98102

99103
// debug in a running dev process.
100-
process.stdin &&
101-
process.stdin.on('data', chunk => {
104+
process.stdin
105+
&& process.stdin.on('data', chunk => {
102106
const parsed = chunk.toString('utf-8').trim()
103107
if (parsed === '*') {
104108
console.log(Object.keys(ctx))
@@ -135,7 +139,10 @@ async function prepareServer (sourceDir, cliOptions = {}, context) {
135139
},
136140
publicPath: ctx.base,
137141
watchOptions: {
138-
ignored: /node_modules/
142+
ignored: [
143+
/node_modules/,
144+
`!${ctx.tempPath}/**`
145+
]
139146
},
140147
historyApiFallback: {
141148
disableDotRule: true,

packages/@vuepress/core/lib/internal-plugins/frontmatterBlock/loader.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ module.exports = function (source, map) {
1212
const cached = cache.get(file)
1313
const parsed = parseStrippedFrontmatter(source)
1414

15-
if (cached &&
16-
cached.data &&
17-
parsed &&
18-
parsed.data &&
19-
JSON.stringify(cached.data) !== JSON.stringify(parsed.data)
15+
if (cached
16+
&& cached.data
17+
&& parsed
18+
&& parsed.data
19+
&& JSON.stringify(cached.data) !== JSON.stringify(parsed.data)
2020
) {
2121
frontmatterEmitter.emit('update')
2222
}

packages/@vuepress/core/lib/internal-plugins/palette/index.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,13 @@ module.exports = (options, ctx) => ({
2222

2323
const themePalette = path.resolve(ctx.themePath, 'styles/palette.styl')
2424
const userPalette = path.resolve(sourceDir, '.vuepress/styles/palette.styl')
25-
.replace(/[\\]+/g, '/')
2625

2726
const themePaletteContent = fs.existsSync(themePalette)
28-
? `@import(${JSON.stringify(themePalette)})`
27+
? `@import(${JSON.stringify(themePalette.replace(/[\\]+/g, '/'))})`
2928
: ''
3029

3130
const userPaletteContent = fs.existsSync(userPalette)
32-
? `@import(${JSON.stringify(userPalette)})`
31+
? `@import(${JSON.stringify(userPalette.replace(/[\\]+/g, '/'))})`
3332
: ''
3433

3534
// user's palette can override theme's palette.
@@ -38,7 +37,7 @@ module.exports = (options, ctx) => ({
3837
if (ctx.parentThemePath) {
3938
const parentThemePalette = path.resolve(ctx.parentThemePath, 'styles/palette.styl')
4039
const parentThemePaletteContent = fs.existsSync(parentThemePalette)
41-
? `@import(${JSON.stringify(parentThemePalette)})`
40+
? `@import(${JSON.stringify(parentThemePalette.replace(/[\\]+/g, '/'))})`
4241
: ''
4342
paletteContent = parentThemePaletteContent + paletteContent
4443
}

packages/@vuepress/core/lib/internal-plugins/style/index.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,21 @@ module.exports = (options, ctx) => ({
1717

1818
const themeStyle = path.resolve(ctx.themePath, 'styles/index.styl')
1919
const userStyle = path.resolve(sourceDir, '.vuepress/styles/index.styl')
20-
.replace(/[\\]+/g, '/')
2120

2221
const themeStyleContent = fs.existsSync(themeStyle)
23-
? `@import(${JSON.stringify(themeStyle)})`
22+
? `@import(${JSON.stringify(themeStyle.replace(/[\\]+/g, '/'))})`
2423
: ''
2524

2625
const userStyleContent = fs.existsSync(userStyle)
27-
? `@import(${JSON.stringify(userStyle)})`
26+
? `@import(${JSON.stringify(userStyle.replace(/[\\]+/g, '/'))})`
2827
: ''
2928

3029
let styleContent = themeStyleContent + userStyleContent
3130

3231
if (ctx.parentThemePath) {
3332
const parentThemeStyle = path.resolve(ctx.parentThemePath, 'styles/index.styl')
3433
const parentThemeStyleContent = fs.existsSync(parentThemeStyle)
35-
? `@import(${JSON.stringify(parentThemeStyle)})`
34+
? `@import(${JSON.stringify(parentThemeStyle.replace(/[\\]+/g, '/'))})`
3635
: ''
3736
styleContent = parentThemeStyleContent + styleContent
3837
}

packages/@vuepress/core/lib/plugin-api/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,8 @@ module.exports = class PluginAPI {
169169
this.options[option.name].add(pluginName, value)
170170
} else if (value !== undefined) {
171171
logger.warn(
172-
`${chalk.gray(pluginName)} ` +
173-
`Invalid value for "option" ${chalk.cyan(option.name)}: ${warnMsg}`
172+
`${chalk.gray(pluginName)} `
173+
+ `Invalid value for "option" ${chalk.cyan(option.name)}: ${warnMsg}`
174174
)
175175
}
176176
return this

packages/@vuepress/core/lib/plugin-api/override/EnhanceAppFilesOption.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ module.exports = class EnhanceAppFilesOption extends AsyncOption {
6767
}
6868
} else {
6969
logger.developer(
70-
chalk.gray(`[${pluginName}] `) +
71-
`${chalk.cyan(enhanceAppFile)} Not Found.`
70+
chalk.gray(`[${pluginName}] `)
71+
+ `${chalk.cyan(enhanceAppFile)} Not Found.`
7272
)
7373
}
7474
}

0 commit comments

Comments
 (0)