diff options
author | Patryk Niedźwiedziński <pniedzwiedzinski19@gmail.com> | 2020-01-29 12:22:09 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-29 12:22:09 +0100 |
commit | 3e5f329cd8c9692e24f5fd56a5e4189bf2202e0d (patch) | |
tree | 8f9140f2326df571a6990df6e9cbd1525f19e374 /components/Posts/PostList | |
parent | 3c2ac6715dfffc2eda38e014ed0b4986ccc7f75a (diff) | |
parent | 0a8355312990db95de3aa4e946b907ed0abf5a12 (diff) | |
download | puszcza-3e5f329cd8c9692e24f5fd56a5e4189bf2202e0d.tar.gz puszcza-3e5f329cd8c9692e24f5fd56a5e4189bf2202e0d.zip |
Merge pull request #26 from 19pdh/feature/json-api
Feature/json api
Diffstat (limited to 'components/Posts/PostList')
-rw-r--r-- | components/Posts/PostList/PurePostList.stories.js | 4 | ||||
-rw-r--r-- | components/Posts/PostList/PurePostList.vue | 2 | ||||
-rw-r--r-- | components/Posts/PostList/index.js | 18 |
3 files changed, 6 insertions, 18 deletions
diff --git a/components/Posts/PostList/PurePostList.stories.js b/components/Posts/PostList/PurePostList.stories.js index a159982..d51a551 100644 --- a/components/Posts/PostList/PurePostList.stories.js +++ b/components/Posts/PostList/PurePostList.stories.js @@ -4,8 +4,8 @@ import { postLink } from '../PostLink.stories' import PurePostList from './PurePostList' -const postLinkNoImage = { ...postLink } -delete postLinkNoImage['image'] +const postLinkNoImage = JSON.parse(JSON.stringify(postLink)) +delete postLinkNoImage.meta['image'] export const posts = [ ...Array(3).fill(postLinkNoImage), diff --git a/components/Posts/PostList/PurePostList.vue b/components/Posts/PostList/PurePostList.vue index 210973e..cdbaffc 100644 --- a/components/Posts/PostList/PurePostList.vue +++ b/components/Posts/PostList/PurePostList.vue @@ -12,7 +12,7 @@ :route="post.route" :title="post.title" :description="post.description" - :image="post.image" + :image="post.meta.image" /> </div> </transition> diff --git a/components/Posts/PostList/index.js b/components/Posts/PostList/index.js index 7e0b1f4..dad805d 100644 --- a/components/Posts/PostList/index.js +++ b/components/Posts/PostList/index.js @@ -1,23 +1,11 @@ import axios from 'axios' -import k from '~/api' +import { apiUrl, parsePosts } from '~/api' import PostList from './PostList' export const getPosts = async () => { - if (process.client) { - let posts = await axios.get(`${window.location.origin}/api/posts.json`) - return parsePosts(posts.data) - } else { - return parsePosts(k.getPosts()) - } + let posts = await axios.get(`${apiUrl}/posts.json`) + return parsePosts(posts.data) } -export const parsePosts = (posts) => - posts.map((post) => ({ - title: post.content.meta.title, - image: post.content.meta.image, - description: post.content.description, - route: post.route, - })) - export default PostList |