Merge pull request #724 from ausir0726/dev

user specified base then add base in html head
This commit is contained in:
Sébastien Chopin 2017-05-17 10:27:02 +02:00 committed by GitHub
commit ed8bc4f874
2 changed files with 5 additions and 1 deletions

View File

@ -42,6 +42,7 @@ class Nuxt {
router: {
mode: 'history',
base: '/',
userSpecifiedBase: false,
middleware: [],
linkActiveClass: 'nuxt-link-active',
linkExactActiveClass: 'nuxt-link-exact-active',
@ -62,6 +63,7 @@ class Nuxt {
// Sanitization
if (options.loading === true) delete options.loading
if (options.router && typeof options.router.middleware === 'string') options.router.middleware = [ options.router.middleware ]
if (options.router && typeof options.router.base === 'string') options.router.userSpecifiedBase = true
if (typeof options.transition === 'string') options.transition = { name: options.transition }
this.options = _.defaultsDeep(options, defaults)
// Env variables

View File

@ -94,7 +94,9 @@ export async function renderRoute (url, context = {}) {
}
const m = context.meta.inject()
let HEAD = m.meta.text() + m.title.text() + m.link.text() + m.style.text() + m.script.text() + m.noscript.text()
HEAD += `<base href="${self.options.router.base}">`
if (self.options.router.userSpecifiedBase) {
HEAD += `<base href="${self.options.router.base}">`
}
HEAD += context.renderResourceHints() + context.renderStyles()
APP += `<script type="text/javascript">window.__NUXT__=${serialize(context.nuxt, { isJSON: true })}</script>`
APP += context.renderScripts()