about summary refs log tree commit diff
path: root/components/PostList/PostList.vue
diff options
context:
space:
mode:
Diffstat (limited to 'components/PostList/PostList.vue')
-rw-r--r--components/PostList/PostList.vue15
1 files changed, 12 insertions, 3 deletions
diff --git a/components/PostList/PostList.vue b/components/PostList/PostList.vue
index 206a73f..2d1bb2d 100644
--- a/components/PostList/PostList.vue
+++ b/components/PostList/PostList.vue
@@ -1,8 +1,9 @@
 <template>
-  <pure-post-list :posts="posts" :loading="loading" />
+  <pure-post-list v-if="rawPosts" :posts="posts" :loading="loading" />
 </template>
 
 <script>
+import k from '~/api'
 import PurePostList from './PurePostList'
 
 export default {
@@ -14,6 +15,12 @@ export default {
       required: false
     }
   },
+  async asyncData() {
+    return {
+      loading: process.client,
+      rawPosts: process.client ? undefined : k.getPosts()
+    }
+  },
   data() {
     return {
       loading: true,
@@ -21,7 +28,9 @@ export default {
     }
   },
   mounted() {
-    this.loadPostsClient()
+    if (process.client && this.rawPosts === undefined) {
+      this.loadPostsClient()
+    }
   },
   computed: {
     posts() {
@@ -46,4 +55,4 @@ export default {
     }
   }
 }
-</script>
\ No newline at end of file
+</script>