Last active
May 31, 2021 08:59
-
-
Save swsalim/f709ff9d9d79dd3a70d50ebd6d081aad to your computer and use it in GitHub Desktop.
Nuxt - Prismic - About Page sample
This file contains hidden or 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
<template> | |
<div> | |
<div class="prose prose-lg"> | |
<prismic-rich-text :field="page.content" /> | |
</div> | |
</div> | |
</template> | |
<script> | |
export default { | |
name: 'AboutPage', | |
async asyncData({ $prismic, error }) { | |
try { | |
const pageContent = (await $prismic.api.getSingle('about_page')).data | |
return { | |
page: pageContent | |
} | |
} catch (e) { | |
error({ statusCode: 404, message: 'Page not found' }) | |
} | |
}, | |
data() { | |
return { | |
page: null | |
} | |
}, | |
head() { | |
return { | |
title: this.$prismic.asText(this.page.meta_title), | |
meta: [ | |
{ | |
hid: 'description', | |
name: 'description', | |
content: this.$prismic | |
.asText(this.page.meta_description) | |
.substring(0, 158) | |
} | |
] | |
} | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment