+ Added layout page and error handler
This commit is contained in:
44
layouts/error.vue
Normal file
44
layouts/error.vue
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
<template>
|
||||||
|
<section class="error bg-image">
|
||||||
|
<div class="splash">
|
||||||
|
<h2 class="heading-1">
|
||||||
|
<span v-if="error.statusCode === 404">Page non trouvée</span>
|
||||||
|
<span v-else>Une erreur est survenue</span>
|
||||||
|
<span>:(</span>
|
||||||
|
</h2>
|
||||||
|
<p>{{ error.message }}</p>
|
||||||
|
<div>
|
||||||
|
<nuxt-link :to="'/'">
|
||||||
|
<AtomsFSButton>Retourner à la page d'accueil</AtomsFSButton>
|
||||||
|
</nuxt-link>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
layout: 'error',
|
||||||
|
props: {
|
||||||
|
error: {
|
||||||
|
type: String,
|
||||||
|
default: ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
.error {
|
||||||
|
position: relative;
|
||||||
|
min-height: inherit;
|
||||||
|
padding: 0 10%;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
|
&:after {
|
||||||
|
background-image: url("/celestials_bg-min.jpg");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -53,22 +53,25 @@ import { fetchCelestial } from '@/api/le-systeme-solaire'
|
|||||||
export default {
|
export default {
|
||||||
name: 'Celestial',
|
name: 'Celestial',
|
||||||
|
|
||||||
data () {
|
async asyncData ({ params, error }) {
|
||||||
return {
|
const slug = params.slug
|
||||||
celestial: false
|
try {
|
||||||
|
const celestial = await fetchCelestial(slug)
|
||||||
|
return { celestial }
|
||||||
|
} catch (err) {
|
||||||
|
error(err)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
mounted () {
|
mounted () {
|
||||||
// Fetches from API...
|
|
||||||
fetchCelestial(this.$route.params.slug)
|
fetchCelestial(this.$route.params.slug)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
this.celestial = res
|
this.celestial = res
|
||||||
return this.celestial
|
return this.celestial
|
||||||
})
|
})
|
||||||
// .catch((err) => {
|
.catch(() => {
|
||||||
// console.error(err)
|
console.log('test')
|
||||||
// })
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user