-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add missing localized home page
- Loading branch information
1 parent
880ea60
commit 49916f3
Showing
1 changed file
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |