mirror of
https://github.com/wahyd4/vuepress.git
synced 2026-08-09 05:16:23 +10:00
properly handle base
This commit is contained in:
+1
-1
@@ -2,5 +2,5 @@
|
||||
node_modules
|
||||
*.log
|
||||
.temp
|
||||
docs/.vuepress/dist
|
||||
vuepress
|
||||
TODOs.md
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
module.exports = {
|
||||
data: {
|
||||
title: 'VuePress'
|
||||
}
|
||||
base: '/vuepress/',
|
||||
title: 'VuePress',
|
||||
dest: 'vuepress'
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
# VuePress
|
||||
|
||||

|
||||
|
||||
> Minimalistic docs generator with Vue component based layout system
|
||||
|
||||
+3
-1
@@ -2,7 +2,9 @@
|
||||
|
||||
## `.vuepress/config.js`
|
||||
|
||||
### baseUrl
|
||||
### base
|
||||
|
||||
### title
|
||||
|
||||
### head
|
||||
|
||||
|
||||
@@ -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
@@ -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
@@ -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
|
||||
})
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user