about summary refs log tree commit diff
path: root/pages/kronika
diff options
context:
space:
mode:
authorPatryk Niedźwiedziński <pniedzwiedzinski19@gmail.com>2020-01-02 19:55:58 +0100
committerPatryk Niedźwiedziński <pniedzwiedzinski19@gmail.com>2020-01-02 19:55:58 +0100
commit53e2f45c6a62bc66185213252378944b19a6c7f9 (patch)
treec6cfb1f70993e760bd62b79773a9f14f57c8291a /pages/kronika
parent6b3b28848f06667f36b4c20bf83ada0e5f578a99 (diff)
downloadpuszcza-53e2f45c6a62bc66185213252378944b19a6c7f9.tar.gz
puszcza-53e2f45c6a62bc66185213252378944b19a6c7f9.zip
Add basic api
Diffstat (limited to 'pages/kronika')
-rw-r--r--pages/kronika/_year/_month/_day/_title/index.vue54
1 files changed, 30 insertions, 24 deletions
diff --git a/pages/kronika/_year/_month/_day/_title/index.vue b/pages/kronika/_year/_month/_day/_title/index.vue
index 9fab1d0..7990abe 100644
--- a/pages/kronika/_year/_month/_day/_title/index.vue
+++ b/pages/kronika/_year/_month/_day/_title/index.vue
@@ -11,42 +11,48 @@
 </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.attributes.title
+          },
+          {
+            hid: 'og:type',
+            property: 'og:type',
+            content: 'article'
+          },
+          {
+            hid: 'og:article:author',
+            property: 'og:article:author',
+            content: this.attributes.author
+          }
+        ]
+      }
     }
   },
   async asyncData({ params }) {
     const { year, month, day, title } = params
-    const post = k.getPost(year, month, day, title)
+    const response = await axios
+      .get(
+        `${process.env.baseUrl}/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
+      attributes: post.meta,
+      content: post.content
     }
   },
   data() {