SHARE
TWEET

Untitled

a guest Oct 22nd, 2019 91 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <template>
  2.     <div>
  3.         <h1>{{ $prismic.richTextAsPlain(aboutContent.main_title) }}</h1>
  4.     </div>
  5. </template>
  6.  
  7. <script>
  8.     export default {
  9.         head () {
  10.             return {
  11.             title: 'Prismic Nuxt.js Blog',
  12.             }
  13.         },
  14.         async asyncData({context, error, req}) {
  15.             try{
  16.             // Query to get API object
  17.             const api = await Prismic.getApi(PrismicConfig.apiEndpoint, {req})
  18.  
  19.             // Query to get blog home content
  20.             const document = await api.getSingle('about')
  21.             let aboutContent = document.data
  22.  
  23.             // // Query to get posts content to preview
  24.             // const blogPosts = await api.query(
  25.             //     Prismic.Predicates.at("document.type", "post"),
  26.             //     { orderings : '[my.post.date desc]' }
  27.             // )
  28.  
  29.  
  30.             // Returns data to be used in template
  31.             return {
  32.                 aboutContent,
  33.                 // posts: blogPosts.results,
  34.                 // image: aboutContent.image.url,
  35.             }
  36.             } catch (e) {
  37.             // Returns error page
  38.             error({ statusCode: 404, message: 'Page not found' })
  39.             }
  40.         },
  41.     }
  42. </script>
  43.  
  44. <style lang="scss" scoped>
  45.  
  46. </style>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top