Created
June 26, 2021 05:46
-
-
Save devmnj/7422df8a4622dd29e9d03f5230e6cc6b to your computer and use it in GitHub Desktop.
Prismic-CMS-Nuxt store example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const state = () => ({ | |
snippets: Object, | |
isLoaded: false, | |
}) | |
export const actions = { | |
async loadSnippets({ commit }) { | |
const document = await this.$prismic.api.query( | |
this.$prismic.predicates.at("document.type", "snippet_type") | |
); | |
commit('setSnippet', document); | |
commit('setLoaded', true); | |
} | |
} | |
export const mutations = { | |
setSnippet(state, code) { | |
state.snippets = code | |
}, | |
setLoaded(state, loaded) { | |
state.isLoaded = loaded | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment