From 50a8648eeb0de1da45af4f9462a83ced04f63218 Mon Sep 17 00:00:00 2001 From: ausir Date: Wed, 17 May 2017 00:58:27 +0800 Subject: [PATCH] user specified base then add base in html head --- lib/nuxt.js | 2 ++ lib/render.js | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/nuxt.js b/lib/nuxt.js index 89d89718aa..6415885000 100644 --- a/lib/nuxt.js +++ b/lib/nuxt.js @@ -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 diff --git a/lib/render.js b/lib/render.js index 4864a0f4d2..66d7fbf960 100644 --- a/lib/render.js +++ b/lib/render.js @@ -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 += `` + if (self.options.router.userSpecifiedBase) { + HEAD += `` + } HEAD += context.renderResourceHints() + context.renderStyles() APP += `` APP += context.renderScripts()