Skip to content

Instantly share code, notes, and snippets.

@devmnj
Created June 26, 2021 05:46
Show Gist options
  • Save devmnj/7422df8a4622dd29e9d03f5230e6cc6b to your computer and use it in GitHub Desktop.
Save devmnj/7422df8a4622dd29e9d03f5230e6cc6b to your computer and use it in GitHub Desktop.
Prismic-CMS-Nuxt store example
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