From 18b44a3aebc56d32060e1d879a8f096eafbf262f Mon Sep 17 00:00:00 2001 From: Patryk Niedźwiedziński Date: Sat, 25 Jan 2020 18:54:05 +0100 Subject: Add image to PostLink --- components/Posts/PostList/PurePostList.stories.js | 15 +++++++++++---- components/Posts/PostList/PurePostList.vue | 9 +++++---- 2 files changed, 16 insertions(+), 8 deletions(-) (limited to 'components/Posts/PostList') diff --git a/components/Posts/PostList/PurePostList.stories.js b/components/Posts/PostList/PurePostList.stories.js index e2c39de..0df4ce3 100644 --- a/components/Posts/PostList/PurePostList.stories.js +++ b/components/Posts/PostList/PurePostList.stories.js @@ -4,27 +4,34 @@ import { postLink } from '../PostLink.stories' import PurePostList from './PurePostList' -export const posts = Array(5).fill(postLink) +const postLinkNoImage = { ...postLink } +delete postLinkNoImage['image'] +console.log(postLinkNoImage) + +export const posts = [ + ...Array(3).fill(postLinkNoImage), + ...Array(5).fill(postLink), +] storiesOf('Posts/PurePostList', module) .add('default', () => { return { components: { PurePostList }, template: ``, - data: () => ({ posts }) + data: () => ({ posts }), } }) .add('loading', () => { return { components: { PurePostList }, template: ``, - data: () => ({ posts: [] }) + data: () => ({ posts: [] }), } }) .add('no posts', () => { return { components: { PurePostList }, template: ``, - data: () => ({ posts: [] }) + data: () => ({ posts: [] }), } }) diff --git a/components/Posts/PostList/PurePostList.vue b/components/Posts/PostList/PurePostList.vue index ace069f..c87b9dc 100644 --- a/components/Posts/PostList/PurePostList.vue +++ b/components/Posts/PostList/PurePostList.vue @@ -12,6 +12,7 @@ :route="post.route" :title="post.title" :description="post.description" + :image="post.image" /> @@ -27,14 +28,14 @@ export default { props: { posts: { type: Array, - required: true + required: true, }, loading: { type: Boolean, required: false, - default: () => false - } - } + default: () => false, + }, + }, } -- cgit 1.4.1 From 1aa3a88b21539aa06572d86324673baeddfbe46f Mon Sep 17 00:00:00 2001 From: Patryk Niedźwiedziński Date: Sat, 25 Jan 2020 19:41:39 +0100 Subject: Add image from meta --- components/Posts/PostList/index.js | 7 ++++--- components/Posts/PostList/parentMixin.js | 4 ++-- package-lock.json | 12 ++++++------ 3 files changed, 12 insertions(+), 11 deletions(-) (limited to 'components/Posts/PostList') diff --git a/components/Posts/PostList/index.js b/components/Posts/PostList/index.js index 11d44ff..7e0b1f4 100644 --- a/components/Posts/PostList/index.js +++ b/components/Posts/PostList/index.js @@ -12,11 +12,12 @@ export const getPosts = async () => { } } -export const parsePosts = posts => - posts.map(post => ({ +export const parsePosts = (posts) => + posts.map((post) => ({ title: post.content.meta.title, + image: post.content.meta.image, description: post.content.description, - route: post.route + route: post.route, })) export default PostList diff --git a/components/Posts/PostList/parentMixin.js b/components/Posts/PostList/parentMixin.js index e5b06ed..801d51c 100644 --- a/components/Posts/PostList/parentMixin.js +++ b/components/Posts/PostList/parentMixin.js @@ -3,7 +3,7 @@ import { getPosts } from './index' export default { async asyncData() { return { - posts: await getPosts() + posts: await getPosts(), } - } + }, } diff --git a/package-lock.json b/package-lock.json index a1270a4..d079c1b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5022,9 +5022,9 @@ } }, "@types/node": { - "version": "12.12.14", - "resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.14.tgz", - "integrity": "sha512-u/SJDyXwuihpwjXy7hOOghagLEV1KdAST6syfnOk6QZAMzZuWZqXy5aYYZbh8Jdpd4escVFP0MvftHNDb9pruA==" + "version": "13.5.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-13.5.0.tgz", + "integrity": "sha512-Onhn+z72D2O2Pb2ql2xukJ55rglumsVo1H6Fmyi8mlU9SvKdBk/pUSUAiBY/d9bAOF7VVWajX3sths/+g6ZiAQ==" }, "@types/normalize-package-data": { "version": "2.4.0", @@ -5094,9 +5094,9 @@ "dev": true }, "@types/tough-cookie": { - "version": "2.3.5", - "resolved": "https://registry.npmjs.org/@types/tough-cookie/-/tough-cookie-2.3.5.tgz", - "integrity": "sha512-SCcK7mvGi3+ZNz833RRjFIxrn4gI1PPR3NtuIS+6vMkvmsGjosqTJwRt5bAEFLRz+wtJMWv8+uOnZf2hi2QXTg==" + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/@types/tough-cookie/-/tough-cookie-2.3.6.tgz", + "integrity": "sha512-wHNBMnkoEBiRAd3s8KTKwIuO9biFtTf0LehITzBhSco+HQI0xkXZbLOD55SW3Aqw3oUkHstkm5SPv58yaAdFPQ==" }, "@types/webpack-env": { "version": "1.14.1", -- cgit 1.4.1 From 32adaba2ded83ab0d69ebeb4d1d839476d94c476 Mon Sep 17 00:00:00 2001 From: Patryk Niedźwiedziński Date: Sat, 25 Jan 2020 22:30:27 +0100 Subject: Remove console log --- components/Posts/PostList/PurePostList.stories.js | 1 - 1 file changed, 1 deletion(-) (limited to 'components/Posts/PostList') diff --git a/components/Posts/PostList/PurePostList.stories.js b/components/Posts/PostList/PurePostList.stories.js index 0df4ce3..a159982 100644 --- a/components/Posts/PostList/PurePostList.stories.js +++ b/components/Posts/PostList/PurePostList.stories.js @@ -6,7 +6,6 @@ import PurePostList from './PurePostList' const postLinkNoImage = { ...postLink } delete postLinkNoImage['image'] -console.log(postLinkNoImage) export const posts = [ ...Array(3).fill(postLinkNoImage), -- cgit 1.4.1