B8f7a improve templates pages for seo (#5)
* Templates * access templates without login also * Set required on UI * Improve templates pages for SEO * test case for Templates * Refactor SitemapController * Cosmetic changes to templates Co-authored-by: Julien Nahum <jhumanj@MacBook-Pro-de-Julien.local>
This commit is contained in:
55
resources/js/store/modules/open/templates.js
vendored
Normal file
55
resources/js/store/modules/open/templates.js
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
import Vue from 'vue'
|
||||
import axios from 'axios'
|
||||
|
||||
// state
|
||||
export const state = {
|
||||
content: [],
|
||||
loading: false
|
||||
}
|
||||
|
||||
// getters
|
||||
export const getters = {
|
||||
getById: (state) => (id) => {
|
||||
if (state.content.length === 0) return null
|
||||
return state.content.find(item => item.id === id)
|
||||
},
|
||||
getBySlug: (state) => (slug) => {
|
||||
if (state.content.length === 0) return null
|
||||
return state.content.find(item => item.slug === slug)
|
||||
},
|
||||
}
|
||||
|
||||
// mutations
|
||||
export const mutations = {
|
||||
set (state, items) {
|
||||
state.content = items
|
||||
},
|
||||
addOrUpdate (state, item) {
|
||||
state.content = state.content.filter((val) => val.id !== item.id)
|
||||
state.content.push(item)
|
||||
},
|
||||
startLoading () {
|
||||
state.loading = true
|
||||
},
|
||||
stopLoading () {
|
||||
state.loading = false
|
||||
}
|
||||
}
|
||||
|
||||
// actions
|
||||
export const actions = {
|
||||
load (context) {
|
||||
context.commit('set', [])
|
||||
context.commit('startLoading')
|
||||
return axios.get('/api/templates').then((response) => {
|
||||
context.commit('set', response.data)
|
||||
context.commit('stopLoading')
|
||||
})
|
||||
},
|
||||
loadIfEmpty ({ context, dispatch, state }) {
|
||||
if (state.content.length === 0) {
|
||||
return dispatch('load')
|
||||
}
|
||||
return Promise.resolve()
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user