From c8565cbb76759c63149c54bab32e850a3b7865b1 Mon Sep 17 00:00:00 2001 From: ManjaroOne666 Date: Tue, 12 Feb 2019 11:20:22 +0000 Subject: [PATCH] site navigation api calls --- TODO.md | 3 +++ components/SiteMenu.vue | 2 +- pages/galleries.vue | 1 - store/index.js | 9 +++++++++ store/navigation.js | 39 ++++++++++++--------------------------- 5 files changed, 25 insertions(+), 29 deletions(-) diff --git a/TODO.md b/TODO.md index b478693..25cb51a 100644 --- a/TODO.md +++ b/TODO.md @@ -15,3 +15,6 @@ * refreshing page on gallery and then quickly usingh history buttons breaks it * broken layout at exactly 40em (640px) breakpoint * galleries page - 'Added non-passive event listener to a scroll-blocking ... event' +* galleries - click on thumb, click on different gallery, click on original gallery + and the thumb list doesn't scroll to correct position to show thumb 0, + it is still showing the thumb that was clicked on first diff --git a/components/SiteMenu.vue b/components/SiteMenu.vue index a4766fb..45cd6cd 100644 --- a/components/SiteMenu.vue +++ b/components/SiteMenu.vue @@ -97,7 +97,7 @@ export default { }, created () { - this.$store.dispatch('navigation/load') + // this.$store.dispatch('navigation/load') }, mounted () { diff --git a/pages/galleries.vue b/pages/galleries.vue index 56ce82c..773cd1f 100644 --- a/pages/galleries.vue +++ b/pages/galleries.vue @@ -31,7 +31,6 @@ export default { }, async asyncData ({ $axios }) { - // TOOD catch errors let { galleries } = await $axios.$get('/api/v1/galleries') return { galleries } }, diff --git a/store/index.js b/store/index.js index dcdb51f..6f810d4 100644 --- a/store/index.js +++ b/store/index.js @@ -1,2 +1,11 @@ export const state = () => ({}) +export const actions = { + async nuxtServerInit ({ commit }, { $axios }) { + const { siteNav, socialNav } = await $axios.$get('/api/v1/navigation') + + commit('navigation/updateSiteNav', siteNav) + commit('navigation/updateSocialNav', socialNav) + } +} + diff --git a/store/navigation.js b/store/navigation.js index ac0e25c..9936f15 100644 --- a/store/navigation.js +++ b/store/navigation.js @@ -1,35 +1,20 @@ -const SITE_NAV = [ - { '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' }, - ] - -const SOCIAL_NAV = [ - { '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' }, - ] - export const state = () => ({ siteNav: [], socialNav: [], }) -export const actions = { - load ({ commit }) { - return new Promise(resolve => { - setTimeout(() => { - commit('updateSiteNav', SITE_NAV) - commit('updateSocialNav', SOCIAL_NAV) - resolve() - }, 300) - }) - } -} - +// export const actions = { +// load ({ commit }) { +// return new Promise(resolve => { +// setTimeout(() => { +// commit('updateSiteNav', SITE_NAV) +// commit('updateSocialNav', SOCIAL_NAV) +// resolve() +// }, 300) +// }) +// } +// } +// export const getters = { siteNav: state => { return state.siteNav