about summary refs log tree commit diff
path: root/pages/kronika/_year
diff options
context:
space:
mode:
Diffstat (limited to 'pages/kronika/_year')
-rw-r--r--pages/kronika/_year/_month/_day/_title/index.vue74
1 files changed, 47 insertions, 27 deletions
diff --git a/pages/kronika/_year/_month/_day/_title/index.vue b/pages/kronika/_year/_month/_day/_title/index.vue
index 9fab1d0..9326ff8 100644
--- a/pages/kronika/_year/_month/_day/_title/index.vue
+++ b/pages/kronika/_year/_month/_day/_title/index.vue
@@ -5,55 +5,74 @@
       <p>Nie znaleziono wpisu</p>
     </div>
     <section v-else class="article">
+      <img
+        v-if="attributes.image"
+        :src="attributes.image"
+        :alt="attributes.title"
+        :title="attributes.title"
+      />
       <article class="content" v-html="content"></article>
     </section>
   </div>
 </template>
 
 <script>
-const md = require('markdown-it')()
-import frontmatter from 'front-matter'
-import k from '~/api'
+import axios from 'axios'
 
 export default {
   head() {
-    return {
-      meta: [
-        {
-          hid: 'og:title',
-          property: 'og:title',
-          content: this.attributes.title
-        },
-        {
-          hid: 'og:type',
-          property: 'og:type',
-          content: 'article'
-        },
-        {
-          hid: 'og:article:author',
-          property: 'og:article:author',
-          content: this.attributes.author
-        }
-      ]
+    if (this.attributes) {
+      return {
+        meta: [
+          {
+            hid: 'og:title',
+            property: 'og:title',
+            content: this.title,
+          },
+          {
+            hid: 'og:type',
+            property: 'og:type',
+            content: 'article',
+          },
+          {
+            hid: 'og:article:author',
+            property: 'og:article:author',
+            content: this.author,
+          },
+          {
+            hid: 'og:image',
+            property: 'og:image',
+            content: this.attributes.image,
+          },
+        ],
+      }
     }
   },
   async asyncData({ params }) {
     const { year, month, day, title } = params
-    const post = k.getPost(year, month, day, title)
+    const response = await axios
+      .get(
+        `https://puszcza.netlify.com/api/posts/${year}/${month}/${day}/${title}.json`
+      )
+      .catch((err) => ({ notFound: true }))
+
+    const post = response.data
 
     if (post === undefined) return { notFound: true }
 
     return {
       params,
-      attributes: post.content.meta,
-      content: post.content.html
+      title: post.title,
+      author: post.author,
+      attributes: post.meta,
+      content: post.content,
     }
   },
   data() {
     return {
-      notFound: false
+      notFound: false,
     }
-  }
+  },
 }
 </script>
 
@@ -69,7 +88,8 @@ export default {
 }
 .article img {
   width: 100%;
-  border-radius: 5px;
+  /*border-radius: 5px;*/
+  box-shadow: inset 0px 0px 100px rgba(0, 0, 0, 0.25);
 }
 
 .article h1 {