-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()
+ })
})