diff --git a/CHANGELOG.md b/CHANGELOG.md index 92e86b0420..229de1874b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,78 @@ + +## [0.14.11](https://github.com/vuejs/vuepress/compare/v0.14.10...v0.14.11) (2019-04-13) + + +### Bug Fixes + +* **$core:** unexpected webpack externals (close: [#451](https://github.com/vuejs/vuepress/issues/451)) ([#1539](https://github.com/vuejs/vuepress/issues/1539)) ([aaf4a7b](https://github.com/vuejs/vuepress/commit/aaf4a7b)) +* **$markdown:** code snippets should not split path on space (close: [#1505](https://github.com/vuejs/vuepress/issues/1505))([#1509](https://github.com/vuejs/vuepress/issues/1509)) ([7b4c4b0](https://github.com/vuejs/vuepress/commit/7b4c4b0)) +* **$theme-default:** hero image resizing ([#873](https://github.com/vuejs/vuepress/issues/873)) ([3cc805d](https://github.com/vuejs/vuepress/commit/3cc805d)) + + + + +## [0.14.10](https://github.com/vuejs/vuepress/compare/v0.14.9...v0.14.10) (2019-03-02) + + +### Bug Fixes + +* missing sidebar button on a mobile homepage (close: [#1355](https://github.com/vuejs/vuepress/issues/1355)) ([#1361](https://github.com/vuejs/vuepress/issues/1361)) ([ae7013f](https://github.com/vuejs/vuepress/commit/ae7013f)), closes [#1159](https://github.com/vuejs/vuepress/issues/1159) + + + + +## [0.14.9](https://github.com/vuejs/vuepress/compare/v0.14.8...v0.14.9) (2019-02-17) + + +### Bug Fixes + +* **$theme-default:** bitbucket edit link goes to wrong link ([#1277](https://github.com/vuejs/vuepress/issues/1277)) ([947a70f](https://github.com/vuejs/vuepress/commit/947a70f)), closes [#1235](https://github.com/vuejs/vuepress/issues/1235) +* **$theme-default:** sidebar button should be hidden when there are no sidebars in mobile side ([#1159](https://github.com/vuejs/vuepress/issues/1159)) ([b7f3ac4](https://github.com/vuejs/vuepress/commit/b7f3ac4)) +* **$core:** remove colon as separator (close: [#1297](https://github.com/vuejs/vuepress/issues/1297)) ([#1305](https://github.com/vuejs/vuepress/issues/1305)) ([3b15f9f](https://github.com/vuejs/vuepress/commit/3b15f9f)) + + + + +## [0.14.8](https://github.com/vuejs/vuepress/compare/v0.14.7...v0.14.8) (2018-11-26) + + +### Features + +* **$markdown:** pass rest options to instantiate markdown-it ([8383329](https://github.com/vuejs/vuepress/commit/8383329)), closes [#1040](https://github.com/vuejs/vuepress/issues/1040) + + + + +## [0.14.7](https://github.com/vuejs/vuepress/compare/v0.14.6...v0.14.7) (2018-11-25) + + +### Bug Fixes + +* **$core:** "index" is dropped in a link with "*index" pattern (close: [#996](https://github.com/vuejs/vuepress/issues/996)) ([1340e37](https://github.com/vuejs/vuepress/commit/1340e37)) + + + + +## [0.14.6](https://github.com/vuejs/vuepress/compare/v0.14.5...v0.14.6) (2018-11-25) + + +### Bug Fixes + +* **$core:** build error when VuePress runs in non-TTY device (close: [#1037](https://github.com/vuejs/vuepress/issues/1037)) ([32c32c9](https://github.com/vuejs/vuepress/commit/32c32c9)) + + + + +## [0.14.5](https://github.com/vuejs/vuepress/compare/v0.14.4...v0.14.5) (2018-11-13) + + +### Bug Fixes + +* **$core:** css cannot be extracted together (close: [#977](https://github.com/vuejs/vuepress/issues/977)) ([600ca3e](https://github.com/vuejs/vuepress/commit/600ca3e)) +* **dev:** Prevent files at node_modules from being watched (close: [#855](https://github.com/vuejs/vuepress/issues/855)) ([#856](https://github.com/vuejs/vuepress/issues/856)) ([2348e75](https://github.com/vuejs/vuepress/commit/2348e75)) + + + ## [0.14.4](https://github.com/vuejs/vuepress/compare/v0.14.3...v0.14.4) (2018-09-15) diff --git a/README.md b/README.md index 3fc1522b56..1e85f2a1f8 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ > Minimalistic docs generator with Vue component based layout system -https://vuepress.vuejs.org/ +https://v0.vuepress.vuejs.org/ ## Features diff --git a/docs/.vuepress/components/Bit.vue b/docs/.vuepress/components/Bit.vue index efb6fa931f..0f3d562117 100644 --- a/docs/.vuepress/components/Bit.vue +++ b/docs/.vuepress/components/Bit.vue @@ -1,8 +1,8 @@ diff --git a/docs/.vuepress/config.js b/docs/.vuepress/config.js index f56003051c..c6b62e7cd5 100644 --- a/docs/.vuepress/config.js +++ b/docs/.vuepress/config.js @@ -29,11 +29,12 @@ module.exports = { repo: 'vuejs/vuepress', editLinks: true, docsDir: 'docs', + docsBranch: '0.x', // #697 Provided by the official algolia team. - algolia: { - apiKey: '3a539aab83105f01761a137c61004d85', - indexName: 'vuepress' - }, + // algolia: { + // apiKey: '3a539aab83105f01761a137c61004d85', + // indexName: 'vuepress' + // }, locales: { '/': { label: 'English', @@ -61,8 +62,12 @@ module.exports = { }, { text: 'Changelog', - link: 'https://github.com/vuejs/vuepress/blob/master/CHANGELOG.md' - } + link: 'https://github.com/vuejs/vuepress/blob/0.x/CHANGELOG.md' + }, + { + text: '1.x', + link: 'https://v1.vuepress.vuejs.org/' + }, ], sidebar: { '/guide/': genSidebarConfig('Guide') @@ -94,8 +99,12 @@ module.exports = { }, { text: 'Changelog', - link: 'https://github.com/vuejs/vuepress/blob/master/CHANGELOG.md' - } + link: 'https://github.com/vuejs/vuepress/blob/0.x/CHANGELOG.md' + }, + { + text: '1.x', + link: 'https://v1.vuepress.vuejs.org/' + }, ], sidebar: { '/zh/guide/': genSidebarConfig('指南') diff --git a/docs/config/README.md b/docs/config/README.md index 1899496557..33bdee0670 100644 --- a/docs/config/README.md +++ b/docs/config/README.md @@ -13,11 +13,11 @@ sidebar: auto - Type: `string` - Default: `/` -The base URL the site will be deployed at. You will need to set this if you plan to deploy your site under a sub path, for example GitHub pages. If you plan to deploy your site to `https://foo.github.io/bar/`, then `base` should be set to `"/bar/"`. It should always start and end with a slash. +The base URL to which the site will be deployed. You will need to set this if you plan to deploy your site under a sub path, for example GitHub pages. If you plan to deploy your site to `https://foo.github.io/bar/`, then `base` should be set to `"/bar/"`. It should always start and end with a forward slash (/). The `base` is automatically prepended to all the URLs that start with `/` in other options, so you only need to specify it once. -**Also see:** +**See also:** - [Base URL](../guide/assets.md#base-url) - [Deploy Guide > Github Pages](../guide/deploy.md#github-pages) @@ -154,7 +154,7 @@ Whether to show line numbers to the left of each code blocks. ### markdown.slugify - Type: `Function` -- Default: [source](https://github.com/vuejs/vuepress/blob/master/lib/markdown/slugify.js) +- Default: [source](https://github.com/vuejs/vuepress/blob/0.x/lib/markdown/slugify.js) Function for transforming header texts into slugs. This affects the ids/links generated for header anchors, table of contents and sidebar links. @@ -199,6 +199,10 @@ module.exports = { ## Build Pipeline +:::tip Configuring CSS Pre-processors +VuePress comes with built-in webpack config for the CSS pre-processors listed below. For more information on installation these or pre-processors without built-in support, see [Using Pre-Processors](../guide/using-vue.md#using-pre-processors) for more information. +::: + ### postcss - Type: `Object` diff --git a/docs/default-theme-config/README.md b/docs/default-theme-config/README.md index f05425ab18..7e2331c87c 100644 --- a/docs/default-theme-config/README.md +++ b/docs/default-theme-config/README.md @@ -39,6 +39,19 @@ If you want to use a completely custom homepage layout, you can also use a [Cust The Navbar may contain your page title, [Search Box](#search-box), [Navbar Links](#navbar-links), [Languages](../guide/i18n.md) and [Repository Link](#git-repo-and-edit-links), all of them depends on your configuration. +### Navbar Logo + +You can add a logo to the navbar via `themeConfig.logo`. Logo can be placed in [public folder](../guide/assets.md#public-files). + +``` js +// .vuepress/config.js +module.exports = { + themeConfig: { + logo: '/assets/img/logo.png', + } +} +``` + ### Navbar Links You can add links to the navbar via `themeConfig.nav`: @@ -448,6 +461,9 @@ $accentColor = #3eaf7c $textColor = #2c3e50 $borderColor = #eaecef $codeBgColor = #282c34 +$badgeTip = #42b983 +$badgeWarning = darken(#ffe564, 35%) +$badgeError = #DA596 ``` ### Existing issues @@ -492,7 +508,7 @@ pageClass: custom-page-class Then you can write CSS targeting that page only: ``` css -/* .vuepress/override.styl */ +/* .vuepress/style.styl */ .theme-container.custom-page-class { /* page-specific rules */ diff --git a/docs/guide/assets.md b/docs/guide/assets.md index 04a6eb31fe..c458a03754 100644 --- a/docs/guide/assets.md +++ b/docs/guide/assets.md @@ -35,6 +35,15 @@ module.exports = { Sometimes you may need to provide static assets that are not directly referenced in any of your markdown or theme components - for example, favicons and PWA icons. In such cases you can put them inside `.vuepress/public` and they will be copied to the root of the generated directory. +Always use absolute paths when calling assets from the `.vuepress/public` directory: + +```css +@font-face { + font-family: 'Roboto'; + src: url('http://github.com/Roboto-Regular.woff2') format('woff2'); +} +``` + ## Base URL If your site is deployed to a non-root URL, you will need to set the `base` option in `.vuepress/config.js`. For example, if you plan to deploy your site to `https://foo.github.io/bar/`, then `base` should be set to `"/bar/"` (it should always start and end with a slash). diff --git a/docs/guide/basic-config.md b/docs/guide/basic-config.md index e333472466..f15caa4685 100644 --- a/docs/guide/basic-config.md +++ b/docs/guide/basic-config.md @@ -2,7 +2,7 @@ ## Config File -Without any configuration, the page is pretty minimal, and the user has no way to navigate around the site. To customize your site, let's first create a `.vuepress` directory inside your docs directory. This is where all VuePress-specific files will be placed in. Your project structure is probably like this: +Without any configuration, the page is pretty minimal, and the user has no way to navigate around the site. To customize your site, let's first create a `.vuepress` directory inside your docs directory. This is where all VuePress-specific files will be placed. Your project structure is probably like this: ``` . @@ -22,7 +22,7 @@ module.exports = { } ``` -If you've got the dev server running, you should see the page now has a header with the title and a search box. VuePress comes with built-in headers-based search - it automatically builds a simple search index from the title, `h2` and `h3` headers from all the pages. +If you've got the dev server running, you should see the page now has a header with the title and a search box. They will be rendered as a `` tag in the page HTML. VuePress comes with built-in headers-based search - it automatically builds a simple search index from the title, `h2` and `h3` headers from all the pages. Consult the [Config Reference](../config/README.md) for a full list of options. diff --git a/docs/guide/markdown.md b/docs/guide/markdown.md index 9831cfb13f..6721464184 100644 --- a/docs/guide/markdown.md +++ b/docs/guide/markdown.md @@ -48,7 +48,7 @@ Given the following directory structure: ### External Links -Outbound links automatically gets `target="_blank" rel="noopener noreferrer"`: +Outbound links automatically get `target="_blank" rel="noopener noreferrer"`: - [vuejs.org](https://vuejs.org) - [VuePress on GitHub](https://github.com/vuejs/vuepress) @@ -57,7 +57,7 @@ You can customize the attributes added to external links by setting [config.mark ## Front Matter -[YAML front matter](https://jekyllrb.com/docs/frontmatter/) is supported out of the box: +[YAML front matter](https://jekyllrb.com/docs/frontmatter/) is supported out of the box when placed at the very beginning of your markdown file: ``` yaml --- diff --git a/docs/zh/default-theme-config/README.md b/docs/zh/default-theme-config/README.md index 94c3b11bf5..5105a71ef8 100644 --- a/docs/zh/default-theme-config/README.md +++ b/docs/zh/default-theme-config/README.md @@ -35,6 +35,19 @@ footer: MIT Licensed | Copyright © 2018-present Evan You 导航栏可能包含你的页面标题、[搜索框](#搜索框)、 [导航栏链接](#导航栏链接)、[多语言切换](../guide/i18n.md)、[仓库链接](#git-仓库和编辑链接),它们均取决于你的配置。 +### 导航栏标志 + +你可以通过 `themeConfig.logo` 增加导航栏标志(Logo),标志可以被放置在[公共文件](../guide/assets.md#public-files): + +``` js +// .vuepress/config.js +module.exports = { + themeConfig: { + logo: '/assets/img/logo.png', + } +} +``` + ### 导航栏链接 你可以通过 `themeConfig.nav` 增加一些导航栏链接: @@ -443,6 +456,9 @@ $accentColor = #3eaf7c $textColor = #2c3e50 $borderColor = #eaecef $codeBgColor = #282c34 +$badgeTip = #42b983 +$badgeWarning = darken(#ffe564, 35%) +$badgeError = #DA596 ``` ### 低版本存在的问题 diff --git a/lib/app/components/Badge.vue b/lib/app/components/Badge.vue index 17e6ba6e7a..faa2e5d285 100644 --- a/lib/app/components/Badge.vue +++ b/lib/app/components/Badge.vue @@ -38,9 +38,9 @@ export default { &.top vertical-align top &.tip, &.green - background-color #42b983 + background-color $badgeTip &.error - background-color #DA5961 //#f66 + background-color $badgeError &.warning, &.warn, &.yellow - background-color darken(#ffe564, 35%) + background-color $badgeWarning diff --git a/lib/default-theme/Home.vue b/lib/default-theme/Home.vue index a172eb9b3c..38270f2fcb 100644 --- a/lib/default-theme/Home.vue +++ b/lib/default-theme/Home.vue @@ -80,6 +80,7 @@ export default { .hero text-align center img + max-width 100% max-height 280px display block margin 3rem auto 1.5rem diff --git a/lib/default-theme/Page.vue b/lib/default-theme/Page.vue index 37d65b41a7..0a45b0b222 100644 --- a/lib/default-theme/Page.vue +++ b/lib/default-theme/Page.vue @@ -147,6 +147,7 @@ export default { : repo return ( base.replace(endingSlashRE, '') + + `/src` + `/${docsBranch}` + (docsDir ? '/' + docsDir.replace(endingSlashRE, '') : '') + path + diff --git a/lib/default-theme/SidebarButton.vue b/lib/default-theme/SidebarButton.vue index 0a22243456..5e823d36a8 100644 --- a/lib/default-theme/SidebarButton.vue +++ b/lib/default-theme/SidebarButton.vue @@ -17,6 +17,7 @@ padding 0.6rem top 0.6rem left 1rem + cursor pointer .icon display block width 1.25rem diff --git a/lib/default-theme/styles/config.styl b/lib/default-theme/styles/config.styl index a57d4484de..d48e0b6d01 100644 --- a/lib/default-theme/styles/config.styl +++ b/lib/default-theme/styles/config.styl @@ -4,6 +4,9 @@ $textColor = #2c3e50 $borderColor = #eaecef $codeBgColor = #282c34 $arrowBgColor = #ccc +$badgeTip = #42b983 +$badgeWarning = darken(#ffe564, 35%) +$badgeError = #DA5961 //#f66 // layout $navbarHeight = 3.6rem diff --git a/lib/default-theme/styles/theme.styl b/lib/default-theme/styles/theme.styl index a733861fa6..f54654a36c 100644 --- a/lib/default-theme/styles/theme.styl +++ b/lib/default-theme/styles/theme.styl @@ -172,8 +172,8 @@ th, td display: block &.no-navbar .content:not(.custom) > h1, h2, h3, h4, h5, h6 - margin-top 1.5rem - padding-top 0 + margin-top 1.5rem + padding-top 0 .sidebar top 0 .custom-layout diff --git a/lib/markdown/index.js b/lib/markdown/index.js index f4942f6ce6..ec39e83299 100644 --- a/lib/markdown/index.js +++ b/lib/markdown/index.js @@ -17,10 +17,10 @@ module.exports = ({ markdown = {}} = {}) => { // allow user config slugify const slugify = markdown.slugify || _slugify - const md = require('markdown-it')({ + const md = require('markdown-it')(Object.assign({ html: true, highlight - }) + }, markdown)) // custom plugins .use(component) .use(highlightLines) diff --git a/lib/markdown/link.js b/lib/markdown/link.js index bbe9550d63..9a6c20c64c 100644 --- a/lib/markdown/link.js +++ b/lib/markdown/link.js @@ -2,7 +2,7 @@ // 1. adding target="_blank" to external links // 2. converting internal links to -const indexRE = /(.*)(index|readme).md(#?.*)$/i +const indexRE = /(^|.*\/)(index|readme).md(#?.*)$/i module.exports = (md, externalAttrs) => { let hasOpenRouterLink = false diff --git a/lib/markdown/snippet.js b/lib/markdown/snippet.js index a677e12f77..b8d93fc753 100644 --- a/lib/markdown/snippet.js +++ b/lib/markdown/snippet.js @@ -24,7 +24,7 @@ module.exports = function snippet (md, options = {}) { const start = pos + 3 const end = state.skipSpacesBack(max, pos) const rawPath = state.src.slice(start, end).trim().replace(/^@/, root) - const filename = rawPath.split(/[{:\s]/).shift() + const filename = rawPath.split(/{/).shift().trim() const content = fs.existsSync(filename) ? fs.readFileSync(filename).toString() : 'Not found: ' + filename const meta = rawPath.replace(filename, '') diff --git a/lib/prepare/index.js b/lib/prepare/index.js index 7561f79158..e6b8ebb409 100644 --- a/lib/prepare/index.js +++ b/lib/prepare/index.js @@ -36,7 +36,7 @@ module.exports = async function prepare (sourceDir) { if (hasUserOverride && !hasUserStyle) { logger.tip( `${chalk.magenta('override.styl')} has been split into 2 APIs, we recommend you upgrade to continue.\n` + - ` See: ${chalk.magenta('https://vuepress.vuejs.org/default-theme-config/#simple-css-override')}` + ` See: ${chalk.magenta('https://v0.vuepress.vuejs.org/default-theme-config/#simple-css-override')}` ) } diff --git a/lib/prepare/util.js b/lib/prepare/util.js index efa96cc9b7..579ae8fd4e 100644 --- a/lib/prepare/util.js +++ b/lib/prepare/util.js @@ -75,6 +75,15 @@ exports.encodePath = function (userpath) { return userpath.split('/').map(item => encodeURIComponent(item)).join('/') } -exports.getGitLastUpdatedTimeStamp = function (filepath) { - return parseInt(spawn.sync('git', ['log', '-1', '--format=%ct', filepath]).stdout.toString('utf-8')) * 1000 +exports.getGitLastUpdatedTimeStamp = function (filePath) { + let lastUpdated + try { + lastUpdated = parseInt(spawn.sync( + 'git', + ['log', '-1', '--format=%ct', path.basename(filePath)], + { cwd: path.dirname(filePath) } + ).stdout.toString('utf-8')) * 1000 + } catch (e) { /* do not handle for now */ } + return lastUpdated } + diff --git a/lib/webpack/createServerConfig.js b/lib/webpack/createServerConfig.js index e9f098354b..f0f05092d8 100644 --- a/lib/webpack/createServerConfig.js +++ b/lib/webpack/createServerConfig.js @@ -11,7 +11,7 @@ module.exports = function createServerConfig (options, cliOptions) { config .target('node') - .externals([/^vue|vue-router$/]) + .externals([/^(vue|vue-router)$/]) .devtool('source-map') // no need to minimize server build diff --git a/package.json b/package.json index afdec2156d..26571fc032 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vuepress", - "version": "0.14.4", + "version": "0.14.11", "description": "Minimalistic doc generator with Vue component based layout system", "main": "lib/index.js", "bin": { @@ -71,7 +71,7 @@ "markdown-it-container": "^2.0.0", "markdown-it-emoji": "^1.4.0", "markdown-it-table-of-contents": "^0.4.0", - "mini-css-extract-plugin": "^0.4.1", + "mini-css-extract-plugin": "0.4.1", "nprogress": "^0.2.0", "optimize-css-assets-webpack-plugin": "^4.0.0", "portfinder": "^1.0.13", diff --git a/test/markdown/__snapshots__/snippet.spec.js.snap b/test/markdown/__snapshots__/snippet.spec.js.snap index 3c97bcddcc..f2f3ae5d89 100644 --- a/test/markdown/__snapshots__/snippet.spec.js.snap +++ b/test/markdown/__snapshots__/snippet.spec.js.snap @@ -1,5 +1,14 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`snippet import snipets when the file has a space in the file path 1`] = ` +
+
 
+
+
+
+
export default function () { // .. } +`; + exports[`snippet import snippet 1`] = `
export default function () {
   // ..
diff --git a/test/markdown/fragments/code-snippet-with-space-in-path.md b/test/markdown/fragments/code-snippet-with-space-in-path.md
new file mode 100644
index 0000000000..57351aadbf
--- /dev/null
+++ b/test/markdown/fragments/code-snippet-with-space-in-path.md
@@ -0,0 +1 @@
+<<< @/test/markdown/fragments/snippet with spaces.js {1}
diff --git a/test/markdown/fragments/snippet with spaces.js b/test/markdown/fragments/snippet with spaces.js
new file mode 100644
index 0000000000..575039d1ec
--- /dev/null
+++ b/test/markdown/fragments/snippet with spaces.js	
@@ -0,0 +1,3 @@
+export default function () {
+  // ..
+}
diff --git a/test/markdown/snippet.spec.js b/test/markdown/snippet.spec.js
index 0131132916..e99ed956ad 100644
--- a/test/markdown/snippet.spec.js
+++ b/test/markdown/snippet.spec.js
@@ -23,4 +23,10 @@ describe('snippet', () => {
     const output = mdH.render(input)
     expect(output).toMatchSnapshot()
   })
+
+  test('import snipets when the file has a space in the file path', async () => {
+    const input = await getFragment('code-snippet-with-space-in-path')
+    const output = mdH.render(input)
+    expect(output).toMatchSnapshot()
+  })
 })