This repository was archived by the owner on May 20, 2024. It is now read-only.
File tree 13 files changed +49
-24
lines changed
13 files changed +49
-24
lines changed Original file line number Diff line number Diff line change 1
1
<template >
2
2
<header class =" site-header" >
3
+ <p v-if =" $store.state.menu === 'Please create a menu document'" class =" logo" >{{ $store.state.menu }}</p >
3
4
<nuxt-link to =" /" class =" logo" >{{ $prismic.asText($store.state.menu.title) }}</nuxt-link >
4
5
<nav >
5
6
<ul >
Original file line number Diff line number Diff line change 1
1
<template >
2
2
<div >
3
+ <header-prismic />
3
4
<nuxt />
4
5
<footer-prismic />
5
6
</div >
6
7
</template >
7
8
8
9
<script >
10
+ import HeaderPrismic from ' ~/components/HeaderPrismic.vue'
9
11
import FooterPrismic from ' ~/components/FooterPrismic.vue'
10
12
11
13
export default {
12
14
components: {
15
+ HeaderPrismic,
13
16
FooterPrismic
14
17
},
15
18
head () {
Original file line number Diff line number Diff line change 1
1
<template >
2
2
<div >
3
- <!-- Vue tag to add header component -->
4
- <header-prismic />
5
3
<div class =" container" >
6
4
<h1 >Page not found</h1 >
7
5
<p >Sorry we were unable to find the page you are looking for.</p >
11
9
</template >
12
10
13
11
<script >
14
- import HeaderPrismic from ' ../components/HeaderPrismic.vue'
15
- import FooterPrismic from ' ~/components/FooterPrismic.vue'
16
-
17
12
export default {
18
13
name: ' NotFound' ,
19
- components: {
20
- HeaderPrismic,
21
- FooterPrismic
22
- }
23
14
}
24
15
</script >
Original file line number Diff line number Diff line change
1
+ <template >
2
+ <div class =" homepage" >
3
+ <header-prismic />
4
+ <nuxt />
5
+ <footer-prismic />
6
+ </div >
7
+ </template >
8
+
9
+ <script >
10
+ import HeaderPrismic from ' ~/components/HeaderPrismic.vue'
11
+ import FooterPrismic from ' ~/components/FooterPrismic.vue'
12
+
13
+ export default {
14
+ components: {
15
+ HeaderPrismic,
16
+ FooterPrismic
17
+ },
18
+ head () {
19
+ return {
20
+ title: ' Prismic Nuxt.js Multi Page Website' ,
21
+ }
22
+ },
23
+ // Called before rendering the layout (even for error page)
24
+ async middleware ({ store, $prismic }) {
25
+ await store .dispatch (' fetchMenu' , $prismic)
26
+ }
27
+ }
28
+ </script >
Original file line number Diff line number Diff line change 1
1
<template >
2
- <section class =" homepage" >
3
- <!-- Vue tag to add header component -->
4
- <header-prismic />
2
+ <section >
5
3
<!-- Banner component -->
6
4
<homepage-banner :banner =" banner" />
7
5
<!-- Slices block component -->
11
9
12
10
<script >
13
11
// Imports for all components
14
- import HeaderPrismic from ' ~/components/HeaderPrismic.vue'
15
12
import HomepageBanner from ' ~/components/HomepageBanner.vue'
16
13
import SlicesBlock from ' ~/components/SlicesBlock.vue'
17
14
18
15
export default {
19
16
name: ' Home' ,
17
+ layout: ' homepage' ,
20
18
components: {
21
- HeaderPrismic,
22
19
HomepageBanner,
23
- SlicesBlock,
20
+ SlicesBlock
24
21
},
25
22
head () {
26
23
return {
Original file line number Diff line number Diff line change 1
1
<template >
2
- <section class =" page" >
3
- <!-- Vue tag to add header component -->
4
- <header-prismic />
2
+ <section >
5
3
<!-- Slices block component -->
6
4
<slices-block :slices =" slices" />
7
5
</section >
8
6
</template >
9
7
10
8
<script >
11
- // Imports for all components
12
- import HeaderPrismic from ' ~/components/HeaderPrismic.vue'
9
+ // Imports for Prismic Slice components
13
10
import SlicesBlock from ' ~/components/SlicesBlock.vue'
14
11
15
12
export default {
16
13
name: ' page' ,
17
14
components: {
18
- HeaderPrismic,
19
- SlicesBlock,
15
+ SlicesBlock
20
16
},
21
17
head () {
22
18
return {
Original file line number Diff line number Diff line change @@ -5,13 +5,22 @@ export const state = () => ({
5
5
export const mutations = {
6
6
SET_MENU ( state , menu ) {
7
7
state . menu = menu
8
+ } ,
9
+ SET_ERROR ( state , error ) {
10
+ state . menu = error
8
11
}
9
12
}
10
13
11
14
export const actions = {
12
15
async fetchMenu ( { commit } , $prismic ) {
13
- const menu = ( await $prismic . api . getSingle ( 'menu' ) ) . data
16
+ try {
17
+ const menu = ( await $prismic . api . getSingle ( 'menu' ) ) . data
14
18
15
- commit ( 'SET_MENU' , menu )
19
+ commit ( 'SET_MENU' , menu )
20
+ } catch ( e ) {
21
+ const error = 'Please create a menu document'
22
+
23
+ commit ( 'SET_ERROR' , error ) ;
24
+ }
16
25
}
17
26
}
You can’t perform that action at this time.
0 commit comments