update: fallbacks if no data
This commit is contained in:
parent
97cc367092
commit
28a561dac0
|
@ -2,10 +2,28 @@ export const state = () => ({})
|
|||
|
||||
export const actions = {
|
||||
async nuxtServerInit ({ commit }, { $axios }) {
|
||||
try {
|
||||
const { siteNav, socialNav } = await $axios.$get('/api/v1/navigation')
|
||||
|
||||
if (siteNav.length < 1) {
|
||||
throw new Error('siteNav empty')
|
||||
}
|
||||
commit('navigation/updateSiteNav', siteNav)
|
||||
commit('navigation/updateSocialNav', socialNav)
|
||||
} catch {
|
||||
commit('navigation/updateSiteNav', [
|
||||
{ "to": "/", "text": "Home", "bgImgUrl": "/img/devices--bw.jpg"},
|
||||
{ "to": "/galleries", "text": "Galleries", "bgImgUrl": "/img/photo-box--bw.jpg" },
|
||||
{ "to": "/services", "text": "Services", "bgImgUrl": "/img/camera--bw.jpg" },
|
||||
{ "to": "/about", "text": "About Me", "bgImgUrl": "/img/silhouette--dark.jpg" },
|
||||
{ "to": "/contact", "text": "Contact Me", "bgImgUrl": "/img/mail--bw.jpg" }
|
||||
])
|
||||
commit('navigation/updateSocialNav', [
|
||||
{ "to": "https://www.instagram.com", "text": "Instagram", "icon": "instagram" },
|
||||
{ "to": "https://www.facebook.com", "text": "Facebook", "icon": "facebook" },
|
||||
{ "to": "https://twitter.com", "text": "Twitter", "icon": "twitter" },
|
||||
{ "to": "https://uk.linkedin.com", "text": "LinkedIn", "icon": "linkedin" }
|
||||
])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue