diff --git a/examples/routes-meta/layouts/default.vue b/examples/routes-meta/layouts/default.vue new file mode 100644 index 0000000000..5012714058 --- /dev/null +++ b/examples/routes-meta/layouts/default.vue @@ -0,0 +1,67 @@ + + + diff --git a/examples/routes-meta/middleware/theme.js b/examples/routes-meta/middleware/theme.js new file mode 100644 index 0000000000..b2cd3f1759 --- /dev/null +++ b/examples/routes-meta/middleware/theme.js @@ -0,0 +1,5 @@ +export default ({ route, app }) => { + // Take the last value (latest route child) + const theme = route.meta.reduce((theme, meta) => meta.theme || theme, 'light') + app.store.commit('SET_THEME', theme) +} diff --git a/examples/routes-meta/nuxt.config.js b/examples/routes-meta/nuxt.config.js new file mode 100644 index 0000000000..e97a8c3a3b --- /dev/null +++ b/examples/routes-meta/nuxt.config.js @@ -0,0 +1,6 @@ +export default { + router: { + middleware: ['theme'] + }, + css: ['wingcss'] +} diff --git a/examples/routes-meta/package.json b/examples/routes-meta/package.json new file mode 100644 index 0000000000..f3abf22fa9 --- /dev/null +++ b/examples/routes-meta/package.json @@ -0,0 +1,12 @@ +{ + "name": "example-hello-world", + "dependencies": { + "nuxt-edge": "latest", + "wingcss": "^1.0.0-beta" + }, + "scripts": { + "dev": "nuxt", + "build": "nuxt build", + "start": "nuxt start" + } +} diff --git a/examples/routes-meta/pages/about.vue b/examples/routes-meta/pages/about.vue new file mode 100644 index 0000000000..89b92384f8 --- /dev/null +++ b/examples/routes-meta/pages/about.vue @@ -0,0 +1,32 @@ + + + + + diff --git a/examples/routes-meta/pages/index.vue b/examples/routes-meta/pages/index.vue new file mode 100644 index 0000000000..2e31ae4815 --- /dev/null +++ b/examples/routes-meta/pages/index.vue @@ -0,0 +1,19 @@ + + + diff --git a/examples/routes-meta/pages/parent.vue b/examples/routes-meta/pages/parent.vue new file mode 100644 index 0000000000..6258e78f51 --- /dev/null +++ b/examples/routes-meta/pages/parent.vue @@ -0,0 +1,16 @@ + + + diff --git a/examples/routes-meta/pages/parent/blue.vue b/examples/routes-meta/pages/parent/blue.vue new file mode 100644 index 0000000000..07ea5f6401 --- /dev/null +++ b/examples/routes-meta/pages/parent/blue.vue @@ -0,0 +1,17 @@ + + + diff --git a/examples/routes-meta/store/index.js b/examples/routes-meta/store/index.js new file mode 100644 index 0000000000..651d618645 --- /dev/null +++ b/examples/routes-meta/store/index.js @@ -0,0 +1,9 @@ +export const state = () => ({ + theme: 'light' +}) + +export const mutations = { + SET_THEME(state, theme) { + state.theme = theme + } +}