From d88948bdeac9cd3b8c8f1c1456198e666e49664e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Chopin?= Date: Thu, 10 Nov 2016 02:19:47 +0100 Subject: [PATCH] map static to / v0.3.0 --- README.md | 11 +++++-- bin/nuxt-build | 2 +- bin/nuxt-dev | 4 ++- bin/nuxt-start | 2 +- examples/hello-world/pages/about.vue | 20 +++++++++---- examples/hello-world/pages/index.vue | 2 +- examples/hello-world/static/nuxt-square.png | Bin 0 -> 4799 bytes examples/with-ava/test/index.test.js | 9 +++++- lib/build/index.js | 10 +++++-- lib/nuxt.js | 31 ++++++++++++-------- lib/server.js | 29 +----------------- package.json | 2 +- 12 files changed, 64 insertions(+), 58 deletions(-) create mode 100644 examples/hello-world/static/nuxt-square.png diff --git a/README.md b/README.md index 0372efb24a..fa9cf1c083 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ So far, we get: - Automatic transpilation and bundling (with webpack and babel) - Hot code reloading - Server rendering and indexing of `./pages` -- Static file serving. `./static/` is mapped to `/static/` +- Static file serving. `./static/` is mapped to `/` - Config file `nuxt.config.js` - Code splitting via webpack @@ -97,8 +97,13 @@ This is mostly used for tests purpose but who knows! ```js nuxt.renderRoute('/about', context) -.then(function (html) { - // HTML +.then(function ({ html, error }) { + // You can check error to know if your app displayed the error page for this route + // Useful to set the correct status status code if an error appended: + if (error) { + return res.status(error.statusCode || 500).send(html) + } + res.send(html) }) .catch(function (error) { // And error appended while rendering the route diff --git a/bin/nuxt-build b/bin/nuxt-build index b20a727b15..780c3fe3d8 100755 --- a/bin/nuxt-build +++ b/bin/nuxt-build @@ -23,5 +23,5 @@ new Nuxt(options) }) .catch((err) => { console.error(err) - process.exit() + process.exit(1) }) diff --git a/bin/nuxt-dev b/bin/nuxt-dev index 069e62aaf0..d772cd4b67 100755 --- a/bin/nuxt-dev +++ b/bin/nuxt-dev @@ -15,6 +15,8 @@ if (typeof options.rootDir !== 'string') { options.rootDir = rootDir } +options.dev = true // Add hot reloading and watching changes + new Nuxt(options) .then((nuxt) => { new Server(nuxt) @@ -22,5 +24,5 @@ new Nuxt(options) }) .catch((err) => { console.error(err) - process.exit() + process.exit(1) }) diff --git a/bin/nuxt-start b/bin/nuxt-start index 1ef5bdd692..b0e0f23820 100755 --- a/bin/nuxt-start +++ b/bin/nuxt-start @@ -25,5 +25,5 @@ new Nuxt(options) }) .catch((err) => { console.error(err) - process.exit() + process.exit(1) }) diff --git a/examples/hello-world/pages/about.vue b/examples/hello-world/pages/about.vue index 934bfbfe09..10b34ee7f8 100755 --- a/examples/hello-world/pages/about.vue +++ b/examples/hello-world/pages/about.vue @@ -1,15 +1,25 @@ diff --git a/examples/hello-world/pages/index.vue b/examples/hello-world/pages/index.vue index 52c820e2d7..83731c889d 100755 --- a/examples/hello-world/pages/index.vue +++ b/examples/hello-world/pages/index.vue @@ -1,6 +1,6 @@