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 0000000000..7f238b598c Binary files /dev/null and b/examples/dynamic-layouts/static/logo.png differ