Skip to content

Commit b5c6e9e

Browse files
committed
properly handle base
1 parent 2a6fe42 commit b5c6e9e

File tree

8 files changed

+17
-10
lines changed

8 files changed

+17
-10
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
node_modules
33
*.log
44
.temp
5-
docs/.vuepress/dist
5+
vuepress
66
TODOs.md

docs/.vuepress/config.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module.exports = {
2-
data: {
3-
title: 'VuePress'
4-
}
2+
base: '/vuepress/',
3+
title: 'VuePress',
4+
dest: 'vuepress'
55
}

docs/README.md

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
# VuePress
22

3-
![logo](/logo.png)
4-
53
> Minimalistic docs generator with Vue component based layout system

docs/config.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
## `.vuepress/config.js`
44

5-
### baseUrl
5+
### base
6+
7+
### title
68

79
### head
810

docs/kitchen/sink.md

+4
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,7 @@ var vm = new Vue({
4545

4646
- Foo is {{ $page.frontmatter.foo }}
4747
- Bar is {{ $page.frontmatter.bar }}
48+
49+
## Using Site Data
50+
51+
<img :src="`${$site.base}logo.png`" alt="logo">

lib/app/app.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import metadataMixin from './metadataMixin'
99
// async components;
1010
// 2. exports siteData
1111
// 3. exports routes
12-
import { routes } from './.temp/siteData'
12+
import { routes, siteData } from './.temp/siteData'
1313

1414
Vue.use(Router)
1515

@@ -27,6 +27,7 @@ routes.push({
2727

2828
export function createApp () {
2929
const router = new Router({
30+
base: siteData.base,
3031
mode: 'history',
3132
fallback: false,
3233
routes

lib/prepare.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ async function resolveOptions (sourceDir) {
4949
outDir: siteConfig.dest
5050
? path.resolve(siteConfig.dest)
5151
: path.resolve(sourceDir, '.vuepress/dist'),
52-
publicPath: siteConfig.baseUrl || '/',
52+
publicPath: siteConfig.base || '/',
5353
pageFiles: await globby(['**/*.md', '!.vuepress'], { cwd: sourceDir })
5454
}
5555

@@ -110,6 +110,8 @@ async function resolveOptions (sourceDir) {
110110

111111
// resolve site data
112112
options.siteData = Object.assign({}, siteConfig.data, {
113+
title: siteConfig.title,
114+
base: siteConfig.base || '/',
113115
pages: pagesData
114116
})
115117

lib/webpack/baseConfig.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ module.exports = function createBaseConfig ({
2323
.output
2424
.path(outDir)
2525
.filename(isProd ? '_assets/js/[name].[chunkhash:8].js' : '_assets/js/[name].js')
26-
.publicPath(publicPath)
26+
.publicPath(isProd ? publicPath : '/')
2727

2828
config.resolve
2929
.set('symlinks', true)

0 commit comments

Comments
 (0)