about summary refs log tree commit diff
path: root/pages
diff options
context:
space:
mode:
Diffstat (limited to 'pages')
-rw-r--r--pages/kronika/_year/_month/_day/_title/index.vue66
-rw-r--r--pages/oboz/2020.vue6
2 files changed, 39 insertions, 33 deletions
diff --git a/pages/kronika/_year/_month/_day/_title/index.vue b/pages/kronika/_year/_month/_day/_title/index.vue
index 331ed7a..d67acbc 100644
--- a/pages/kronika/_year/_month/_day/_title/index.vue
+++ b/pages/kronika/_year/_month/_day/_title/index.vue
@@ -17,47 +17,55 @@
 </template>
 
 <script>
-const md = require('markdown-it')()
-import frontmatter from 'front-matter'
-import k from '~/api'
+import axios from 'axios'
+
+import { apiUrl } from '~/api'
 
 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,
-        },
-        {
-          hid: 'og:image',
-          property: 'og:image',
-          content: this.attributes.image,
-        },
-      ],
+    if (!this.notFound && 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(`${apiUrl}/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() {
diff --git a/pages/oboz/2020.vue b/pages/oboz/2020.vue
index 119220d..c1b73c4 100644
--- a/pages/oboz/2020.vue
+++ b/pages/oboz/2020.vue
@@ -43,7 +43,7 @@ import CampMap from '~/components/CampMap'
 import EmptyCampStory from '~/components/Posts/EmptyCampStory'
 import GoogleDriveLink from '~/components/GoogleDriveLink'
 
-import { parsePosts } from '~/components/Posts/PostList'
+import { apiUrl, parsePosts } from '~/api'
 
 export default {
   components: {
@@ -67,9 +67,7 @@ export default {
   },
   async asyncData() {
     try {
-      let posts = await axios.get(
-        `https://puszcza.netlify.com/api/category/oboz2020.json`
-      )
+      let posts = await axios.get(`${apiUrl}/category/oboz2020.json`)
       console.log(posts)
       return {
         posts: parsePosts(posts.data),