about summary refs log tree commit diff
path: root/components/Posts/PostLink.vue
diff options
context:
space:
mode:
authorPatryk Niedźwiedziński <pniedzwiedzinski19@gmail.com>2020-01-25 18:54:05 +0100
committerPatryk Niedźwiedziński <pniedzwiedzinski19@gmail.com>2020-01-25 18:54:05 +0100
commit18b44a3aebc56d32060e1d879a8f096eafbf262f (patch)
tree19c53a43fe9aa48f7716ccb5cc65e39c0f62f1ef /components/Posts/PostLink.vue
parent1b74216fc4afa740991dcc9986eb6843c5b07a59 (diff)
downloadpuszcza-18b44a3aebc56d32060e1d879a8f096eafbf262f.tar.gz
puszcza-18b44a3aebc56d32060e1d879a8f096eafbf262f.zip
Add image to PostLink
Diffstat (limited to 'components/Posts/PostLink.vue')
-rw-r--r--components/Posts/PostLink.vue34
1 files changed, 25 insertions, 9 deletions
diff --git a/components/Posts/PostLink.vue b/components/Posts/PostLink.vue
index 8d0a669..5f7d5bf 100644
--- a/components/Posts/PostLink.vue
+++ b/components/Posts/PostLink.vue
@@ -1,9 +1,12 @@
 <template>
   <div class="post-link">
     <a :href="route">
-      <div class="post-container">
-        <h4 class="post-title">{{ title }}</h4>
-        <p class="post-description">{{ shortenedDescription }}...</p>
+      <div>
+        <div class="image" :style="`background-image: url('${image}')`" />
+        <div class="post-container">
+          <h4 class="post-title">{{ title }}</h4>
+          <p class="post-description">{{ shortenedDescription }}...</p>
+        </div>
       </div>
     </a>
   </div>
@@ -15,23 +18,28 @@ export default {
   props: {
     title: {
       type: String,
-      required: true
+      required: true,
     },
     description: {
       type: String,
-      default: ''
+      default: '',
     },
     route: {
       type: String,
-      required: true
-    }
+      required: true,
+    },
+    image: {
+      type: String,
+      required: false,
+      default: () => '/assets/og/default.jpg',
+    },
   },
   computed: {
     shortenedDescription() {
       const first30Words = this.description.split(' ').slice(0, 30)
       return first30Words.join(' ')
-    }
-  }
+    },
+  },
 }
 </script>
 
@@ -60,6 +68,7 @@ export default {
 .post-link .post-container {
   padding: 20px;
   height: 100%;
+  padding-top: 0;
 }
 
 .post-link .post-title {
@@ -71,4 +80,11 @@ export default {
   color: #484848;
   font-size: 0.9em;
 }
+
+.post-link .image {
+  height: 300px;
+  background-repeat: no-repeat;
+  background-size: cover;
+  background-position: center;
+}
 </style>