home teasers and static pages #796
This commit is contained in:
+3
-1
@@ -4,12 +4,14 @@ import Vuex from 'vuex'
|
||||
import Corpus from './modules/corpus'
|
||||
import Search from './modules/search'
|
||||
import History from './modules/history'
|
||||
import Colophon from './modules/colophon'
|
||||
|
||||
Vue.use(Vuex)
|
||||
export default new Vuex.Store({
|
||||
modules: {
|
||||
Corpus,
|
||||
Search,
|
||||
History
|
||||
History,
|
||||
Colophon
|
||||
}
|
||||
})
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
import { REST } from 'api/rest-axios'
|
||||
import router from '../../router'
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
router,
|
||||
// initial state
|
||||
state: {
|
||||
colophon: [],
|
||||
colophonHome: []
|
||||
},
|
||||
|
||||
// getters
|
||||
getters: {},
|
||||
|
||||
// mutations
|
||||
mutations: {
|
||||
setColophon (state, colophon) {
|
||||
state.colophon = colophon
|
||||
for (let i = 0; i < colophon.length; i++) {
|
||||
if (colophon[i].uuid !== 'schema') {
|
||||
state.colophonHome.push(colophon[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// actions
|
||||
actions: {
|
||||
getColophon ({ dispatch, commit, state }) {
|
||||
REST.get(`${window.apipath}/colophon`, {})
|
||||
.then(({ data }) => {
|
||||
console.log('colophon getColophon REST: data', data)
|
||||
// commit('setColophon', data.content)
|
||||
dispatch('getPages', data.content.pages)
|
||||
.then((pages) => {
|
||||
console.log('all pages returned: pages', pages)
|
||||
commit('setColophon', pages)
|
||||
})
|
||||
})
|
||||
.catch((error) => {
|
||||
console.warn('Issue with getColophon', error)
|
||||
Promise.reject(error)
|
||||
})
|
||||
},
|
||||
// async get pages
|
||||
getPages ({ dispatch, commit, state }, pages) {
|
||||
return Promise.all(pages.map(function (page) {
|
||||
return REST.get(`${window.apipath}/colophon/` + page.uuid, {})
|
||||
.then(({ data }) => {
|
||||
console.log('colophon getPages REST: page, data', page, data)
|
||||
// // work arround
|
||||
// if (!Array.isArray(data.content)) {
|
||||
// data.content = [data.content]
|
||||
// }
|
||||
return data.content
|
||||
})
|
||||
.catch((error) => {
|
||||
console.warn('colophon Issue with getPages', error)
|
||||
Promise.reject(error)
|
||||
})
|
||||
}))
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user