diff --git a/examples/vuex-store-modules/README.md b/examples/vuex-store-modules/README.md deleted file mode 100644 index dc0a710fb0..0000000000 --- a/examples/vuex-store-modules/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# Nuxt with [Vuex](https://vuex.vuejs.org/) and store modules - -> Vuex is a state management pattern + library for Vue.js applications. - -Read on Vuex modules [here](https://vuex.vuejs.org/guide/modules.html) - -https://nuxtjs.org/guide/vuex-store#modules-files diff --git a/examples/vuex-store-modules/package.json b/examples/vuex-store-modules/package.json deleted file mode 100644 index 2b30bc27ab..0000000000 --- a/examples/vuex-store-modules/package.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "example-vuex-store-modules", - "dependencies": { - "nuxt": "latest" - }, - "scripts": { - "dev": "nuxt", - "build": "nuxt build", - "start": "nuxt start", - "post-update": "yarn upgrade --latest" - } -} diff --git a/examples/vuex-store-modules/pages/about.vue b/examples/vuex-store-modules/pages/about.vue deleted file mode 100644 index 45fa28a173..0000000000 --- a/examples/vuex-store-modules/pages/about.vue +++ /dev/null @@ -1,12 +0,0 @@ - diff --git a/examples/vuex-store-modules/pages/index.vue b/examples/vuex-store-modules/pages/index.vue deleted file mode 100644 index c923869555..0000000000 --- a/examples/vuex-store-modules/pages/index.vue +++ /dev/null @@ -1,45 +0,0 @@ - - - diff --git a/examples/vuex-store-modules/store/index.js b/examples/vuex-store-modules/store/index.js deleted file mode 100644 index b22221c9c7..0000000000 --- a/examples/vuex-store-modules/store/index.js +++ /dev/null @@ -1,9 +0,0 @@ -export const state = () => ({ - counter: 0 -}) - -export const mutations = { - increment(state) { - state.counter++ - } -} diff --git a/examples/vuex-store/README.md b/examples/vuex-store/README.md index 45d3fc36a8..dc0a710fb0 100644 --- a/examples/vuex-store/README.md +++ b/examples/vuex-store/README.md @@ -1,7 +1,7 @@ -# Nuxt with [Vuex](https://vuex.vuejs.org/) +# Nuxt with [Vuex](https://vuex.vuejs.org/) and store modules +> Vuex is a state management pattern + library for Vue.js applications. ->Vuex is a state management pattern + library for Vue.js applications. +Read on Vuex modules [here](https://vuex.vuejs.org/guide/modules.html) - -https://nuxtjs.org/examples/vuex-store +https://nuxtjs.org/guide/vuex-store#modules-files diff --git a/examples/vuex-store/pages/index.vue b/examples/vuex-store/pages/index.vue index 61eb1e9cfc..135ccc061c 100644 --- a/examples/vuex-store/pages/index.vue +++ b/examples/vuex-store/pages/index.vue @@ -1,13 +1,25 @@ @@ -19,7 +31,7 @@ export default { 'counter' ]), // fetch(context) is called by the server-side - // and nuxt before instantiating the component + // and before instantiating the component fetch({ store }) { store.commit('increment') }, diff --git a/examples/vuex-store-modules/pages/todos.vue b/examples/vuex-store/pages/todos.vue similarity index 100% rename from examples/vuex-store-modules/pages/todos.vue rename to examples/vuex-store/pages/todos.vue diff --git a/examples/vuex-store-modules/pages/website.vue b/examples/vuex-store/pages/website.vue similarity index 100% rename from examples/vuex-store-modules/pages/website.vue rename to examples/vuex-store/pages/website.vue diff --git a/examples/vuex-store-modules/store/articles.js b/examples/vuex-store/store/articles.js similarity index 100% rename from examples/vuex-store-modules/store/articles.js rename to examples/vuex-store/store/articles.js diff --git a/examples/vuex-store-modules/store/articles/comments.js b/examples/vuex-store/store/articles/comments.js similarity index 81% rename from examples/vuex-store-modules/store/articles/comments.js rename to examples/vuex-store/store/articles/comments.js index 4092086eee..035c8a62da 100644 --- a/examples/vuex-store-modules/store/articles/comments.js +++ b/examples/vuex-store/store/articles/comments.js @@ -6,12 +6,6 @@ export const state = () => ({ ] }) -export const mutations = { - add(state, title) { - state.list.push(title) - } -} - export const getters = { get(state) { return state.list diff --git a/examples/vuex-store/store/articles/comments/mutations.js b/examples/vuex-store/store/articles/comments/mutations.js new file mode 100644 index 0000000000..d1c61f3e79 --- /dev/null +++ b/examples/vuex-store/store/articles/comments/mutations.js @@ -0,0 +1,5 @@ +export default { + add(state, title) { + state.list.push(title) + } +} diff --git a/examples/vuex-store/store/todos/getters.js b/examples/vuex-store/store/todos/getters.js new file mode 100644 index 0000000000..35e8dac849 --- /dev/null +++ b/examples/vuex-store/store/todos/getters.js @@ -0,0 +1,5 @@ +export default { + todos(state) { + return state.list + } +} diff --git a/examples/vuex-store-modules/store/todos.js b/examples/vuex-store/store/todos/mutations.js similarity index 50% rename from examples/vuex-store-modules/store/todos.js rename to examples/vuex-store/store/todos/mutations.js index f482ec1242..656b7657f1 100644 --- a/examples/vuex-store-modules/store/todos.js +++ b/examples/vuex-store/store/todos/mutations.js @@ -1,8 +1,4 @@ -export const state = () => ({ - list: [] -}) - -export const mutations = { +export default { add(state, { text }) { state.list.push({ text, @@ -14,9 +10,3 @@ export const mutations = { todo.done = !todo.done } } - -export const getters = { - todos(state) { - return state.list - } -} diff --git a/examples/vuex-store/store/todos/state.js b/examples/vuex-store/store/todos/state.js new file mode 100644 index 0000000000..0d94e8f20c --- /dev/null +++ b/examples/vuex-store/store/todos/state.js @@ -0,0 +1,3 @@ +export default () => ({ + list: [] +})