about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPatryk Niedźwiedziński <pniedzwiedzinski19@gmail.com>2020-01-29 10:56:31 +0100
committerPatryk Niedźwiedziński <pniedzwiedzinski19@gmail.com>2020-01-29 10:56:31 +0100
commit1c046bd96752feb1bbc0fb0e7b5fca94f299664a (patch)
treea2c5993f2c39846fef8e39c2496563edb1422c66
parenta46cabb3ed27fc099f0eb68c4b073fea6615e822 (diff)
downloadpuszcza-1c046bd96752feb1bbc0fb0e7b5fca94f299664a.tar.gz
puszcza-1c046bd96752feb1bbc0fb0e7b5fca94f299664a.zip
Add apiUrl
-rw-r--r--api/index.js15
-rw-r--r--components/Posts/PostList/index.js15
-rw-r--r--pages/kronika/_year/_month/_day/_title/index.vue8
-rw-r--r--pages/oboz/2020.vue5
4 files changed, 17 insertions, 26 deletions
diff --git a/api/index.js b/api/index.js
index 5658365..7843302 100644
--- a/api/index.js
+++ b/api/index.js
@@ -1,7 +1,10 @@
-import Kronikarz from 'kronikarz'
+export const apiUrl = 'https://puszcza.netlify.com/api'
 
-const POSTS_PATH = './content/wpisy'
-
-const k = new Kronikarz(POSTS_PATH)
-
-export default k
+export const parsePosts = (posts) =>
+  posts.map((post) => ({
+    title: post.title,
+    image: post.image,
+    description: post.description,
+    route: post.path,
+    meta: post.meta,
+  }))
diff --git a/components/Posts/PostList/index.js b/components/Posts/PostList/index.js
index 2b8ad92..dad805d 100644
--- a/components/Posts/PostList/index.js
+++ b/components/Posts/PostList/index.js
@@ -1,22 +1,11 @@
 import axios from 'axios'
 
-import k from '~/api'
+import { apiUrl, parsePosts } from '~/api'
 import PostList from './PostList'
 
 export const getPosts = async () => {
-  let posts = await axios.get(
-    `https://feature-json-api--puszcza.netlify.com/api/posts.json`
-  )
+  let posts = await axios.get(`${apiUrl}/posts.json`)
   return parsePosts(posts.data)
 }
 
-export const parsePosts = (posts) =>
-  posts.map((post) => ({
-    title: post.title,
-    image: post.image,
-    description: post.description,
-    route: post.path,
-    meta: post.meta,
-  }))
-
 export default PostList
diff --git a/pages/kronika/_year/_month/_day/_title/index.vue b/pages/kronika/_year/_month/_day/_title/index.vue
index 485bfc4..0bd6c80 100644
--- a/pages/kronika/_year/_month/_day/_title/index.vue
+++ b/pages/kronika/_year/_month/_day/_title/index.vue
@@ -19,9 +19,11 @@
 <script>
 import axios from 'axios'
 
+import { apiUrl } from '~/api'
+
 export default {
   head() {
-    if (this.attributes) {
+    if (!this.notFound) {
       return {
         meta: [
           {
@@ -51,9 +53,7 @@ export default {
   async asyncData({ params }) {
     const { year, month, day, title } = params
     const response = await axios
-      .get(
-        `https://feature-json-api--puszcza.netlify.com/api/posts/${year}/${month}/${day}/${title}.json`
-      )
+      .get(`${apiUrl}/posts/${year}/${month}/${day}/${title}.json`)
       .catch((err) => ({ notFound: true }))
 
     const post = response.data
diff --git a/pages/oboz/2020.vue b/pages/oboz/2020.vue
index 119220d..e26cde6 100644
--- a/pages/oboz/2020.vue
+++ b/pages/oboz/2020.vue
@@ -44,6 +44,7 @@ import EmptyCampStory from '~/components/Posts/EmptyCampStory'
 import GoogleDriveLink from '~/components/GoogleDriveLink'
 
 import { parsePosts } from '~/components/Posts/PostList'
+import { apiUrl } from '~/api'
 
 export default {
   components: {
@@ -67,9 +68,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),