mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-30 17:37:14 +00:00
user specified base then add base in html head
This commit is contained in:
parent
0d9627b488
commit
50a8648eeb
@ -42,6 +42,7 @@ class Nuxt {
|
|||||||
router: {
|
router: {
|
||||||
mode: 'history',
|
mode: 'history',
|
||||||
base: '/',
|
base: '/',
|
||||||
|
userSpecifiedBase: false,
|
||||||
middleware: [],
|
middleware: [],
|
||||||
linkActiveClass: 'nuxt-link-active',
|
linkActiveClass: 'nuxt-link-active',
|
||||||
linkExactActiveClass: 'nuxt-link-exact-active',
|
linkExactActiveClass: 'nuxt-link-exact-active',
|
||||||
@ -62,6 +63,7 @@ class Nuxt {
|
|||||||
// Sanitization
|
// Sanitization
|
||||||
if (options.loading === true) delete options.loading
|
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.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 }
|
if (typeof options.transition === 'string') options.transition = { name: options.transition }
|
||||||
this.options = _.defaultsDeep(options, defaults)
|
this.options = _.defaultsDeep(options, defaults)
|
||||||
// Env variables
|
// Env variables
|
||||||
|
@ -94,7 +94,9 @@ export async function renderRoute (url, context = {}) {
|
|||||||
}
|
}
|
||||||
const m = context.meta.inject()
|
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()
|
let HEAD = m.meta.text() + m.title.text() + m.link.text() + m.style.text() + m.script.text() + m.noscript.text()
|
||||||
|
if (self.options.router.userSpecifiedBase) {
|
||||||
HEAD += `<base href="${self.options.router.base}">`
|
HEAD += `<base href="${self.options.router.base}">`
|
||||||
|
}
|
||||||
HEAD += context.renderResourceHints() + context.renderStyles()
|
HEAD += context.renderResourceHints() + context.renderStyles()
|
||||||
APP += `<script type="text/javascript">window.__NUXT__=${serialize(context.nuxt, { isJSON: true })}</script>`
|
APP += `<script type="text/javascript">window.__NUXT__=${serialize(context.nuxt, { isJSON: true })}</script>`
|
||||||
APP += context.renderScripts()
|
APP += context.renderScripts()
|
||||||
|
Loading…
Reference in New Issue
Block a user