properly handle base

This commit is contained in:
Evan You
2018-04-05 17:32:23 -04:00
parent 2a6fe420dc
commit b5c6e9eda2
8 changed files with 17 additions and 10 deletions
+1 -1
View File
@@ -2,5 +2,5 @@
node_modules
*.log
.temp
docs/.vuepress/dist
vuepress
TODOs.md
+3 -3
View File
@@ -1,5 +1,5 @@
module.exports = {
data: {
title: 'VuePress'
}
base: '/vuepress/',
title: 'VuePress',
dest: 'vuepress'
}
-2
View File
@@ -1,5 +1,3 @@
# VuePress
![logo](/logo.png)
> Minimalistic docs generator with Vue component based layout system
+3 -1
View File
@@ -2,7 +2,9 @@
## `.vuepress/config.js`
### baseUrl
### base
### title
### head
+4
View File
@@ -45,3 +45,7 @@ var vm = new Vue({
- Foo is {{ $page.frontmatter.foo }}
- Bar is {{ $page.frontmatter.bar }}
## Using Site Data
<img :src="`${$site.base}logo.png`" alt="logo">
+2 -1
View File
@@ -9,7 +9,7 @@ import metadataMixin from './metadataMixin'
// async components;
// 2. exports siteData
// 3. exports routes
import { routes } from './.temp/siteData'
import { routes, siteData } from './.temp/siteData'
Vue.use(Router)
@@ -27,6 +27,7 @@ routes.push({
export function createApp () {
const router = new Router({
base: siteData.base,
mode: 'history',
fallback: false,
routes
+3 -1
View File
@@ -49,7 +49,7 @@ async function resolveOptions (sourceDir) {
outDir: siteConfig.dest
? path.resolve(siteConfig.dest)
: path.resolve(sourceDir, '.vuepress/dist'),
publicPath: siteConfig.baseUrl || '/',
publicPath: siteConfig.base || '/',
pageFiles: await globby(['**/*.md', '!.vuepress'], { cwd: sourceDir })
}
@@ -110,6 +110,8 @@ async function resolveOptions (sourceDir) {
// resolve site data
options.siteData = Object.assign({}, siteConfig.data, {
title: siteConfig.title,
base: siteConfig.base || '/',
pages: pagesData
})
+1 -1
View File
@@ -23,7 +23,7 @@ module.exports = function createBaseConfig ({
.output
.path(outDir)
.filename(isProd ? '_assets/js/[name].[chunkhash:8].js' : '_assets/js/[name].js')
.publicPath(publicPath)
.publicPath(isProd ? publicPath : '/')
config.resolve
.set('symlinks', true)