diff options
author | Patryk Niedźwiedziński <pniedzwiedzinski19@gmail.com> | 2019-12-05 11:56:11 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-05 11:56:11 -0500 |
commit | cd7fa1fb5d499e51b9f2bc833159ee4581b8f2a8 (patch) | |
tree | be10296e0268295db20c536af045c5df6c829a0e /components/Posts/PostList/index.js | |
parent | 070b7725be5fb0db486e9370bea5648c16c8bbfe (diff) | |
parent | 34908ab59f58f3d5b229867c84d8b51b07c777d4 (diff) | |
download | puszcza-cd7fa1fb5d499e51b9f2bc833159ee4581b8f2a8.tar.gz puszcza-cd7fa1fb5d499e51b9f2bc833159ee4581b8f2a8.zip |
Merge pull request #13 from 19pdh/storybook
Storybook
Diffstat (limited to 'components/Posts/PostList/index.js')
-rw-r--r-- | components/Posts/PostList/index.js | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/components/Posts/PostList/index.js b/components/Posts/PostList/index.js new file mode 100644 index 0000000..11d44ff --- /dev/null +++ b/components/Posts/PostList/index.js @@ -0,0 +1,22 @@ +import axios from 'axios' + +import k 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()) + } +} + +export const parsePosts = posts => + posts.map(post => ({ + title: post.content.meta.title, + description: post.content.description, + route: post.route + })) + +export default PostList |