Skip to content

Commit

Permalink
fix: add missing localized home page
Browse files Browse the repository at this point in the history
  • Loading branch information
yannbertrand committed Jan 3, 2023
1 parent 880ea60 commit 49916f3
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions pages/pix-site/localized-home.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<template>
<div class="index">
<prismic-custom-slice-zone :slices="slices" />
</div>
</template>

<script>
import { documentFetcher } from '~/services/document-fetcher'
export default {
name: 'LocalizedHome',
nuxtI18n: {
paths: {
fr: '/',
'fr-fr': '/',
'en-gb': '/',
'fr-be': '/',
},
},
async asyncData({ app, req, error, currentPagePath }) {
try {
const document = await documentFetcher(
app.$prismic,
app.i18n,
req
).getPageByUid('index-pix-site')
const latestNewsItems = await documentFetcher(
app.$prismic,
app.i18n,
req
).findNewsItems({ page: 1, pageSize: 3 })
return {
currentPagePath,
meta: document.data.meta,
document: document.data.body,
title: document.data.title[0].text,
latestNewsItems,
}
} catch (e) {
console.error({ e })
error({ statusCode: 404, message: 'Page not found' })
}
},
head() {
const meta = this.$getMeta(this.meta, this.currentPagePath, this.$prismic)
return {
title: `${this.title} | Pix`,
meta,
}
},
computed: {
slices() {
return this.document.map((slice, index) => {
if (slice.slice_type === 'latest_news') {
slice.primary.latest_news_items = this.latestNewsItems
}
return slice
})
},
},
}
</script>

0 comments on commit 49916f3

Please sign in to comment.