From 0a9477dc7b14c8595f76ac797a4e519bcdad5d65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Chopin?= Date: Fri, 17 Mar 2017 18:03:12 +0100 Subject: [PATCH] Dynamic layouts example --- examples/dynamic-layouts/README.md | 3 ++ examples/dynamic-layouts/layouts/error.vue | 25 ++++++++++++ examples/dynamic-layouts/layouts/mobile.vue | 37 ++++++++++++++++++ examples/dynamic-layouts/middleware/mobile.js | 4 ++ examples/dynamic-layouts/nuxt.config.js | 10 +++++ examples/dynamic-layouts/package.json | 11 ++++++ examples/dynamic-layouts/pages/about.vue | 17 ++++++++ examples/dynamic-layouts/pages/index.vue | 12 ++++++ examples/dynamic-layouts/static/logo.png | Bin 0 -> 4252 bytes 9 files changed, 119 insertions(+) create mode 100644 examples/dynamic-layouts/README.md create mode 100644 examples/dynamic-layouts/layouts/error.vue create mode 100644 examples/dynamic-layouts/layouts/mobile.vue create mode 100644 examples/dynamic-layouts/middleware/mobile.js create mode 100644 examples/dynamic-layouts/nuxt.config.js create mode 100644 examples/dynamic-layouts/package.json create mode 100644 examples/dynamic-layouts/pages/about.vue create mode 100644 examples/dynamic-layouts/pages/index.vue create mode 100644 examples/dynamic-layouts/static/logo.png diff --git a/examples/dynamic-layouts/README.md b/examples/dynamic-layouts/README.md new file mode 100644 index 0000000000..baba1117a5 --- /dev/null +++ b/examples/dynamic-layouts/README.md @@ -0,0 +1,3 @@ +# Dynamic Layouts + +https://nuxtjs.org/examples/layouts diff --git a/examples/dynamic-layouts/layouts/error.vue b/examples/dynamic-layouts/layouts/error.vue new file mode 100644 index 0000000000..3ba6fabb69 --- /dev/null +++ b/examples/dynamic-layouts/layouts/error.vue @@ -0,0 +1,25 @@ + + + + + diff --git a/examples/dynamic-layouts/layouts/mobile.vue b/examples/dynamic-layouts/layouts/mobile.vue new file mode 100644 index 0000000000..db8735a00e --- /dev/null +++ b/examples/dynamic-layouts/layouts/mobile.vue @@ -0,0 +1,37 @@ + + + diff --git a/examples/dynamic-layouts/middleware/mobile.js b/examples/dynamic-layouts/middleware/mobile.js new file mode 100644 index 0000000000..276889f41d --- /dev/null +++ b/examples/dynamic-layouts/middleware/mobile.js @@ -0,0 +1,4 @@ +export default function (ctx) { + let userAgent = ctx.req ? ctx.req.headers['user-agent'] : navigator.userAgent + ctx.isMobile = /mobile/i.test(userAgent) +} diff --git a/examples/dynamic-layouts/nuxt.config.js b/examples/dynamic-layouts/nuxt.config.js new file mode 100644 index 0000000000..ab913e20b1 --- /dev/null +++ b/examples/dynamic-layouts/nuxt.config.js @@ -0,0 +1,10 @@ +module.exports = { + head: { + meta: [ + { content: 'width=device-width,initial-scale=1', name: 'viewport' } + ] + }, + router: { + middleware: ['mobile'] + } +} diff --git a/examples/dynamic-layouts/package.json b/examples/dynamic-layouts/package.json new file mode 100644 index 0000000000..cd97f88ca2 --- /dev/null +++ b/examples/dynamic-layouts/package.json @@ -0,0 +1,11 @@ +{ + "name": "nuxt-dynamic-layouts", + "dependencies": { + "nuxt": "latest" + }, + "scripts": { + "dev": "nuxt", + "build": "nuxt build", + "start": "nuxt start" + } +} diff --git a/examples/dynamic-layouts/pages/about.vue b/examples/dynamic-layouts/pages/about.vue new file mode 100644 index 0000000000..8ed01c381f --- /dev/null +++ b/examples/dynamic-layouts/pages/about.vue @@ -0,0 +1,17 @@ + + + diff --git a/examples/dynamic-layouts/pages/index.vue b/examples/dynamic-layouts/pages/index.vue new file mode 100644 index 0000000000..4095e47a00 --- /dev/null +++ b/examples/dynamic-layouts/pages/index.vue @@ -0,0 +1,12 @@ + + + diff --git a/examples/dynamic-layouts/static/logo.png b/examples/dynamic-layouts/static/logo.png new file mode 100644 index 0000000000000000000000000000000000000000..7f238b598c85d618ae0c601fec86455a2a1ed4e1 GIT binary patch literal 4252 zcmV;N5M%F&P)g` zMQS+^rII|YPa_znyK06zSH+#;sbvrYPbJ-$aIST{pJ152GFi-#g|FGax5DoN-#l6N znP8Z{O75z3{VsQE_oQAM(2rSB>QQ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