From 2553900590a0cf0ea08bfe539da1d58f6eb9b65c Mon Sep 17 00:00:00 2001 From: Davyd McColl Date: Tue, 23 Oct 2018 19:57:48 +0200 Subject: [PATCH 1/7] fix: guard against missing data elements by using lodash.get --- package-lock.json | 28 +++++++++++++++++++++------- src/Utilities/MapArticle.js | 12 ++++++++++++ src/components/Article.vue | 8 ++------ src/components/Articles.vue | 15 ++++++--------- 4 files changed, 41 insertions(+), 22 deletions(-) create mode 100644 src/Utilities/MapArticle.js diff --git a/package-lock.json b/package-lock.json index 5df107a..0c9ea97 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4807,12 +4807,14 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -4827,17 +4829,20 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -4954,7 +4959,8 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -4966,6 +4972,7 @@ "version": "1.0.0", "bundled": true, "dev": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -4980,6 +4987,7 @@ "version": "3.0.4", "bundled": true, "dev": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -4987,12 +4995,14 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "minipass": { "version": "2.2.4", "bundled": true, "dev": true, + "optional": true, "requires": { "safe-buffer": "^5.1.1", "yallist": "^3.0.0" @@ -5011,6 +5021,7 @@ "version": "0.5.1", "bundled": true, "dev": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -5091,7 +5102,8 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -5103,6 +5115,7 @@ "version": "1.4.0", "bundled": true, "dev": true, + "optional": true, "requires": { "wrappy": "1" } @@ -5224,6 +5237,7 @@ "version": "1.0.2", "bundled": true, "dev": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", diff --git a/src/Utilities/MapArticle.js b/src/Utilities/MapArticle.js new file mode 100644 index 0000000..b657ba5 --- /dev/null +++ b/src/Utilities/MapArticle.js @@ -0,0 +1,12 @@ +import _ from 'lodash'; + +export function mapArticle(article) { + return { + title: _.get(article, 'title.value') || '(Article has no title)', + imageLink: _.get(article, 'teaserImage.value[0].url'), + postDate: this.formatDate(_.get(article, 'postDate.value')), + summary: _.get(article, 'summary.value') || 'No summary yet', + link: `/${this.language}/articles/${_.get(article, 'system.id')}`, + bodyCopyElement: _.get(article, 'bodyCopy') + }; +} diff --git a/src/components/Article.vue b/src/components/Article.vue index 6b8119d..e9dc896 100644 --- a/src/components/Article.vue +++ b/src/components/Article.vue @@ -37,6 +37,7 @@ import { ArticleStore } from '../Stores/Article' import dateFormat from 'dateformat'; import { dateFormats } from '../Utilities/LanguageCodes' import RichTextElement from './RichTextElement.vue' +import { mapArticle } from '../Utilities/MapArticle'; export default { name: 'Article', @@ -46,12 +47,7 @@ export default { }), computed: { articleData: function(){ - return ({ - title: this.article.title.value, - imageLink: this.article.teaserImage.value[0].url, - postDate: this.formatDate(this.article.postDate.value), - bodyCopyElement: this.article.bodyCopy, - }) + return mapArticle(this.article); } }, watch: { diff --git a/src/components/Articles.vue b/src/components/Articles.vue index ff0c126..d334cc4 100644 --- a/src/components/Articles.vue +++ b/src/components/Articles.vue @@ -10,12 +10,14 @@
- + Article {{ article.title }}
{{article.postDate}} @@ -39,6 +41,7 @@ import dateFormat from 'dateformat'; import { ArticleStore } from '../Stores/Article'; import { dateFormats } from '../Utilities/LanguageCodes'; +import { mapArticle } from '../Utilities/MapArticle'; export default { name: 'Articles', @@ -49,13 +52,7 @@ export default { }), computed: { articlesData: function() { - return this.articles.map(article => ({ - title: article.title.value, - imageLink: article.teaserImage.value[0].url, - postDate: this.formatDate(article.postDate.value), - summary: article.summary.value, - link: `/${this.language}/articles/${article.system.id}` - })); + return this.articles.map(mapArticle); } }, watch: { @@ -66,7 +63,7 @@ export default { }, methods: { formatDate: function(value) { - return dateFormat(value, 'mmmm d'); + return value ? dateFormat(value, 'mmmm d') : undefined; }, onChange: function() { this.articles = ArticleStore.getArticles( From eede6770ee699002fe4ebfc640cade97815951bc Mon Sep 17 00:00:00 2001 From: Davyd McColl Date: Sat, 3 Nov 2018 20:05:33 +0200 Subject: [PATCH 2/7] fix: don't refer to `this` in mapArticle - require dateFormat and i18n functions from caller fix: add translations for fallback values --- package-lock.json | 13 +++++++++---- src/Localization/en-US.json | 4 ++++ src/Localization/es-ES.json | 5 +++++ src/Utilities/MapArticle.js | 9 +++++---- src/components/Article.vue | 2 +- src/components/Articles.vue | 4 ++-- 6 files changed, 26 insertions(+), 11 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0c9ea97..9836d35 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4786,7 +4786,8 @@ "ansi-regex": { "version": "2.1.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "aproba": { "version": "1.2.0", @@ -5201,7 +5202,8 @@ "safe-buffer": { "version": "5.1.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "safer-buffer": { "version": "2.1.2", @@ -5257,6 +5259,7 @@ "version": "3.0.1", "bundled": true, "dev": true, + "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -5300,12 +5303,14 @@ "wrappy": { "version": "1.0.2", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "yallist": { "version": "3.0.2", "bundled": true, - "dev": true + "dev": true, + "optional": true } } }, diff --git a/src/Localization/en-US.json b/src/Localization/en-US.json index e0ff1b8..6a6a875 100644 --- a/src/Localization/en-US.json +++ b/src/Localization/en-US.json @@ -56,5 +56,9 @@ "contact": "Contact", "cityStateZip": "Illinois 60601, USA", "allRightsReserved": "All rights reserved." + }, + "Articles": { + "noTitleValue": "(Article has no title)", + "noSummaryValue": "No summary yet" } } diff --git a/src/Localization/es-ES.json b/src/Localization/es-ES.json index 9620ece..4486341 100644 --- a/src/Localization/es-ES.json +++ b/src/Localization/es-ES.json @@ -56,5 +56,10 @@ "contact": "Contacto", "cityStateZip": "Illinois 60601, EE.UU.", "allRightsReserved": "Todos los derechos reservados." + }, + "Articles": { + "noTitleValue": "(El artículo no tiene título)", + "noSummaryValue": "Article has no title" } + } diff --git a/src/Utilities/MapArticle.js b/src/Utilities/MapArticle.js index b657ba5..85625fd 100644 --- a/src/Utilities/MapArticle.js +++ b/src/Utilities/MapArticle.js @@ -1,11 +1,12 @@ import _ from 'lodash'; -export function mapArticle(article) { +export function mapArticle( + article, formatDateFn, i18nFn) { return { - title: _.get(article, 'title.value') || '(Article has no title)', + title: _.get(article, 'title.value', i18nFn('noArticleValue')), imageLink: _.get(article, 'teaserImage.value[0].url'), - postDate: this.formatDate(_.get(article, 'postDate.value')), - summary: _.get(article, 'summary.value') || 'No summary yet', + postDate: formatDateFn(_.get(article, 'postDate.value')), + summary: _.get(article, 'summary.value', i18nFn('noSummaryValue')), link: `/${this.language}/articles/${_.get(article, 'system.id')}`, bodyCopyElement: _.get(article, 'bodyCopy') }; diff --git a/src/components/Article.vue b/src/components/Article.vue index e9dc896..30fa857 100644 --- a/src/components/Article.vue +++ b/src/components/Article.vue @@ -47,7 +47,7 @@ export default { }), computed: { articleData: function(){ - return mapArticle(this.article); + return mapArticle(this.article, this.formatDate.bind(this), this.$t.bind(this)); } }, watch: { diff --git a/src/components/Articles.vue b/src/components/Articles.vue index d334cc4..019809f 100644 --- a/src/components/Articles.vue +++ b/src/components/Articles.vue @@ -10,7 +10,7 @@
- Date: Tue, 6 Nov 2018 09:50:33 +0200 Subject: [PATCH 3/7] fix: rather use lambda mapping for Array.map fn --- src/components/Articles.vue | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/Articles.vue b/src/components/Articles.vue index 019809f..f5d9c13 100644 --- a/src/components/Articles.vue +++ b/src/components/Articles.vue @@ -52,7 +52,9 @@ export default { }), computed: { articlesData: function() { - return this.articles.map(mapArticle, this.formatDate.bind(this), this.$t.bind(this)); + const formatDat = this.formatDate.bind(this); + const $t = this.$t.bind(this); + return this.articles.map(article => mapArticle(article, formatDate, $t)); } }, watch: { From 97f27407fa1d560783d107cb74e6da8ac4067a45 Mon Sep 17 00:00:00 2001 From: Davyd McColl Date: Tue, 6 Nov 2018 21:51:58 +0200 Subject: [PATCH 4/7] fix: remove last vestiges of `this` from `mapArticle` --- src/Utilities/MapArticle.js | 4 ++-- src/components/Article.vue | 6 +++++- src/components/Articles.vue | 6 ++++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/Utilities/MapArticle.js b/src/Utilities/MapArticle.js index 85625fd..f7df691 100644 --- a/src/Utilities/MapArticle.js +++ b/src/Utilities/MapArticle.js @@ -1,13 +1,13 @@ import _ from 'lodash'; export function mapArticle( - article, formatDateFn, i18nFn) { + article, formatDateFn, i18nFn, language) { return { title: _.get(article, 'title.value', i18nFn('noArticleValue')), imageLink: _.get(article, 'teaserImage.value[0].url'), postDate: formatDateFn(_.get(article, 'postDate.value')), summary: _.get(article, 'summary.value', i18nFn('noSummaryValue')), - link: `/${this.language}/articles/${_.get(article, 'system.id')}`, + link: `/${language}/articles/${_.get(article, 'system.id')}`, bodyCopyElement: _.get(article, 'bodyCopy') }; } diff --git a/src/components/Article.vue b/src/components/Article.vue index 30fa857..b0999b0 100644 --- a/src/components/Article.vue +++ b/src/components/Article.vue @@ -47,7 +47,11 @@ export default { }), computed: { articleData: function(){ - return mapArticle(this.article, this.formatDate.bind(this), this.$t.bind(this)); + return mapArticle( + this.article, + this.formatDate.bind(this), + this.$t.bind(this), + this.language); } }, watch: { diff --git a/src/components/Articles.vue b/src/components/Articles.vue index f5d9c13..e639bfe 100644 --- a/src/components/Articles.vue +++ b/src/components/Articles.vue @@ -52,9 +52,11 @@ export default { }), computed: { articlesData: function() { - const formatDat = this.formatDate.bind(this); + const formatDate = this.formatDate.bind(this); const $t = this.$t.bind(this); - return this.articles.map(article => mapArticle(article, formatDate, $t)); + return this.articles.map(article => + mapArticle(article, formatDate, $t, this.language) + ); } }, watch: { From 3bd093e044a7368013f4a30a6c3c5bb65173b7a9 Mon Sep 17 00:00:00 2001 From: Davyd McColl Date: Wed, 14 Nov 2018 19:17:08 +0200 Subject: [PATCH 5/7] refactor: map article data locally in Articles.vue and Article.vue --- src/Client.js | 4 ++-- src/Utilities/MapArticle.js | 13 ------------- src/components/Article.vue | 24 ++++++++++++------------ src/components/Articles.vue | 14 ++++++++------ 4 files changed, 22 insertions(+), 33 deletions(-) delete mode 100644 src/Utilities/MapArticle.js diff --git a/src/Client.js b/src/Client.js index 5981083..563d2c2 100644 --- a/src/Client.js +++ b/src/Client.js @@ -4,8 +4,8 @@ import { selectedProjectCookieName, defaultProjectId } from './Utilities/Selecte // kentico cloud import { DeliveryClient, TypeResolver } from 'kentico-cloud-delivery'; -const projectId = ''; -const previewApiKey = ''; +const projectId = 'dbb5068c-9ed9-00f3-7898-d3b46e31f9ed'; +const previewApiKey = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJqdGkiOiI5Y2YxNzFjYTFjOWM0ODgwOGZkNzdhOTI2MzI5Njg4YSIsImlhdCI6IjE1NDE1MzMxNTciLCJleHAiOiIxODg3MTMzMTU3IiwicHJvamVjdF9pZCI6ImRiYjUwNjhjOWVkOTAwZjM3ODk4ZDNiNDZlMzFmOWVkIiwidmVyIjoiMS4wLjAiLCJhdWQiOiJwcmV2aWV3LmRlbGl2ZXIua2VudGljb2Nsb3VkLmNvbSJ9.GEvEf_9u3vZEOJGQIoi0ps_TWeC5YbEPg5gGDrTMM1Y'; // models import { AboutUs } from './Models/AboutUs' diff --git a/src/Utilities/MapArticle.js b/src/Utilities/MapArticle.js deleted file mode 100644 index f7df691..0000000 --- a/src/Utilities/MapArticle.js +++ /dev/null @@ -1,13 +0,0 @@ -import _ from 'lodash'; - -export function mapArticle( - article, formatDateFn, i18nFn, language) { - return { - title: _.get(article, 'title.value', i18nFn('noArticleValue')), - imageLink: _.get(article, 'teaserImage.value[0].url'), - postDate: formatDateFn(_.get(article, 'postDate.value')), - summary: _.get(article, 'summary.value', i18nFn('noSummaryValue')), - link: `/${language}/articles/${_.get(article, 'system.id')}`, - bodyCopyElement: _.get(article, 'bodyCopy') - }; -} diff --git a/src/components/Article.vue b/src/components/Article.vue index b0999b0..cef86e5 100644 --- a/src/components/Article.vue +++ b/src/components/Article.vue @@ -33,11 +33,11 @@ \ No newline at end of file diff --git a/src/components/Articles.vue b/src/components/Articles.vue index e639bfe..185c6c4 100644 --- a/src/components/Articles.vue +++ b/src/components/Articles.vue @@ -41,7 +41,7 @@ import dateFormat from 'dateformat'; import { ArticleStore } from '../Stores/Article'; import { dateFormats } from '../Utilities/LanguageCodes'; -import { mapArticle } from '../Utilities/MapArticle'; +import _ from 'lodash'; export default { name: 'Articles', @@ -52,11 +52,13 @@ export default { }), computed: { articlesData: function() { - const formatDate = this.formatDate.bind(this); - const $t = this.$t.bind(this); - return this.articles.map(article => - mapArticle(article, formatDate, $t, this.language) - ); + return this.articles.map(article => ({ + title: _.get(article, 'title.value', this.$t('Articles.noTitleValue')), + imageLink: _.get(article, 'teaserImage.value[0].url'), + link: `/${this.language}/articles/${_.get(article, 'system.id')}`, + postDate: this.formatDate(_.get(article, 'postDate.value')), + summary: _.get(article, 'summary.value', this.$t('Articles.noSummaryValue')) + })); } }, watch: { From 5bb637e8db855ff045dda519334df18355adec89 Mon Sep 17 00:00:00 2001 From: Simply007 Date: Fri, 16 Nov 2018 14:55:29 +0100 Subject: [PATCH 6/7] showcase how to handle articles is missing values on preview --- src/Client.js | 4 ++-- src/Localization/en-US.json | 7 +++++-- src/Localization/es-ES.json | 7 +++++-- src/components/Article.vue | 13 ++++++++++--- src/components/Articles.vue | 11 +++++++---- src/components/LatestArticles.vue | 19 +++++++++++++++---- vue.cli.config | 5 +++++ 7 files changed, 49 insertions(+), 17 deletions(-) create mode 100644 vue.cli.config diff --git a/src/Client.js b/src/Client.js index 563d2c2..0dfbc1f 100644 --- a/src/Client.js +++ b/src/Client.js @@ -4,8 +4,8 @@ import { selectedProjectCookieName, defaultProjectId } from './Utilities/Selecte // kentico cloud import { DeliveryClient, TypeResolver } from 'kentico-cloud-delivery'; -const projectId = 'dbb5068c-9ed9-00f3-7898-d3b46e31f9ed'; -const previewApiKey = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJqdGkiOiI5Y2YxNzFjYTFjOWM0ODgwOGZkNzdhOTI2MzI5Njg4YSIsImlhdCI6IjE1NDE1MzMxNTciLCJleHAiOiIxODg3MTMzMTU3IiwicHJvamVjdF9pZCI6ImRiYjUwNjhjOWVkOTAwZjM3ODk4ZDNiNDZlMzFmOWVkIiwidmVyIjoiMS4wLjAiLCJhdWQiOiJwcmV2aWV3LmRlbGl2ZXIua2VudGljb2Nsb3VkLmNvbSJ9.GEvEf_9u3vZEOJGQIoi0ps_TWeC5YbEPg5gGDrTMM1Y'; +const projectId = 'cbf6934c-956f-0006-799e-42054f50c3a6';//'dbb5068c-9ed9-00f3-7898-d3b46e31f9ed'; +const previewApiKey = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJqdGkiOiIwY2ZkYjI3NDRkMDE0OWY4ODgzMjU2NjI1MTBkNWJmOCIsImlhdCI6IjE1NDIzNjk5MTAiLCJleHAiOiIxODg3OTY5OTEwIiwicHJvamVjdF9pZCI6ImNiZjY5MzRjOTU2ZjAwMDY3OTllNDIwNTRmNTBjM2E2IiwidmVyIjoiMS4wLjAiLCJhdWQiOiJwcmV2aWV3LmRlbGl2ZXIua2VudGljb2Nsb3VkLmNvbSJ9.SJsYWfghbiSNOkIKEIcXatKjGr-V5u89vSgjpza3ik4';//'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJqdGkiOiI5Y2YxNzFjYTFjOWM0ODgwOGZkNzdhOTI2MzI5Njg4YSIsImlhdCI6IjE1NDE1MzMxNTciLCJleHAiOiIxODg3MTMzMTU3IiwicHJvamVjdF9pZCI6ImRiYjUwNjhjOWVkOTAwZjM3ODk4ZDNiNDZlMzFmOWVkIiwidmVyIjoiMS4wLjAiLCJhdWQiOiJwcmV2aWV3LmRlbGl2ZXIua2VudGljb2Nsb3VkLmNvbSJ9.GEvEf_9u3vZEOJGQIoi0ps_TWeC5YbEPg5gGDrTMM1Y'; // models import { AboutUs } from './Models/AboutUs' diff --git a/src/Localization/en-US.json b/src/Localization/en-US.json index 6a6a875..8e39a17 100644 --- a/src/Localization/en-US.json +++ b/src/Localization/en-US.json @@ -57,8 +57,11 @@ "cityStateZip": "Illinois 60601, USA", "allRightsReserved": "All rights reserved." }, - "Articles": { + "Article": { "noTitleValue": "(Article has no title)", - "noSummaryValue": "No summary yet" + "noTeaserValue": "(Article has no teaser image)", + "noSummaryValue": "No summary filled", + "noBodyCopyValue" : "No body copy element filled", + "noPostDateValue": "No post date filled" } } diff --git a/src/Localization/es-ES.json b/src/Localization/es-ES.json index 4486341..ea0b9b1 100644 --- a/src/Localization/es-ES.json +++ b/src/Localization/es-ES.json @@ -57,9 +57,12 @@ "cityStateZip": "Illinois 60601, EE.UU.", "allRightsReserved": "Todos los derechos reservados." }, - "Articles": { + "Article": { "noTitleValue": "(El artículo no tiene título)", - "noSummaryValue": "Article has no title" + "noTeaserValue": "(El artículo no tiene imagen teaser)", + "noSummaryValue": "Sin resumen lleno", + "noBodyCopyValue" : "Ningún elemento body copy lleno", + "noPostDateValue": "Ningún elemento post date lleno" } } diff --git a/src/components/Article.vue b/src/components/Article.vue index cef86e5..9c77025 100644 --- a/src/components/Article.vue +++ b/src/components/Article.vue @@ -15,18 +15,25 @@
+ {{ $t('Article.noTeaserValue') }}
+ {{ $t('Article.noBodyCopyValue')}}
@@ -48,10 +55,10 @@ export default { computed: { articleData: function() { return { - title: _.get(this.article, 'title.value', this.$t('Articles.noTitleValue')), + title: _.get(this.article, 'title.value') || this.$t('Article.noTitleValue'), imageLink: _.get(this.article, 'teaserImage.value[0].url'), postDate: this.formatDate(_.get(this.article, 'postDate.value')), - bodyCopyElement: _.get(this.article, 'bodyCopy') + bodyCopyElement: _.get(this.article, 'bodyCopy') || this.$t('Article.noBodyCopyValue') }; } }, @@ -63,7 +70,7 @@ export default { }, methods: { formatDate: function(value){ - return dateFormat(value, 'dddd, mmmm d, yyyy'); + return value ? dateFormat(value, 'dddd, mmmm d, yyyy') : this.$t('Article.noPostDateValue'); }, onChange: function(){ this.article = ArticleStore.getArticle(this.$route.params.articleId, this.language); diff --git a/src/components/Articles.vue b/src/components/Articles.vue index 185c6c4..dc7f0bb 100644 --- a/src/components/Articles.vue +++ b/src/components/Articles.vue @@ -17,7 +17,10 @@ :src="article.imageLink" :title="'Article ' + article.title" /> - Article {{ article.title }} + {{ $t('Article.noTeaserValue') }}
{{article.postDate}} @@ -53,11 +56,11 @@ export default { computed: { articlesData: function() { return this.articles.map(article => ({ - title: _.get(article, 'title.value', this.$t('Articles.noTitleValue')), + title: _.get(article, 'title.value') || this.$t('Article.noTitleValue'), imageLink: _.get(article, 'teaserImage.value[0].url'), link: `/${this.language}/articles/${_.get(article, 'system.id')}`, postDate: this.formatDate(_.get(article, 'postDate.value')), - summary: _.get(article, 'summary.value', this.$t('Articles.noSummaryValue')) + summary: _.get(article, 'summary.value') || this.$t('Article.noSummaryValue') })); } }, @@ -69,7 +72,7 @@ export default { }, methods: { formatDate: function(value) { - return value ? dateFormat(value, 'mmmm d') : undefined; + return value ? dateFormat(value, 'mmmm d') : this.$t('Article.noPostDateValue'); }, onChange: function() { this.articles = ArticleStore.getArticles( diff --git a/src/components/LatestArticles.vue b/src/components/LatestArticles.vue index 5450b1a..dd374d1 100644 --- a/src/components/LatestArticles.vue +++ b/src/components/LatestArticles.vue @@ -13,11 +13,16 @@
+ {{ $t('Article.noTeaserValue') }}
@@ -42,11 +47,16 @@
+ {{ $t('Article.noTeaserValue') }}
{{article.postDate}} @@ -68,6 +78,7 @@ import { ArticleStore } from '../Stores/Article' import dateFormat from 'dateformat' import { dateFormats } from '../Utilities/LanguageCodes' +import _ from 'lodash'; export default { name: 'latest-articles', @@ -79,9 +90,9 @@ export default { computed: { articlesData: function(){ return this.articles.map(article => ({ - imageLink : article.teaserImage.value[0].url, - postDate : this.formatDate(article.postDate.value), - summary : article.summary.value, + imageLink: _.get(article, 'teaserImage.value[0].url'), + postDate : this.formatDate(_.get(article, 'postDate.value')), + summary : _.get(article, 'summary.value') || this.$t('Article.noSummaryValue'), link : `/${this.language}/articles/${article.system.id}`, })) } @@ -94,7 +105,7 @@ export default { }, methods: { formatDate: function(value){ - return dateFormat(value, 'mmmm d'); + return value ? dateFormat(value, 'mmmm d') : this.$t('Article.noPostDateValue'); }, onChange: function(){ this.articles = ArticleStore.getArticles(this.articleCount, this.language); diff --git a/vue.cli.config b/vue.cli.config new file mode 100644 index 0000000..097ed48 --- /dev/null +++ b/vue.cli.config @@ -0,0 +1,5 @@ +module.exports = { + configureWebpack: { + devtool: 'source-map' + } +} \ No newline at end of file From f45697b6843b39f3295e6a01828f5736513b94aa Mon Sep 17 00:00:00 2001 From: Davyd McColl Date: Sun, 18 Nov 2018 16:26:36 +0200 Subject: [PATCH 7/7] fix: remove client/project ids --- src/Client.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Client.js b/src/Client.js index 0dfbc1f..5981083 100644 --- a/src/Client.js +++ b/src/Client.js @@ -4,8 +4,8 @@ import { selectedProjectCookieName, defaultProjectId } from './Utilities/Selecte // kentico cloud import { DeliveryClient, TypeResolver } from 'kentico-cloud-delivery'; -const projectId = 'cbf6934c-956f-0006-799e-42054f50c3a6';//'dbb5068c-9ed9-00f3-7898-d3b46e31f9ed'; -const previewApiKey = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJqdGkiOiIwY2ZkYjI3NDRkMDE0OWY4ODgzMjU2NjI1MTBkNWJmOCIsImlhdCI6IjE1NDIzNjk5MTAiLCJleHAiOiIxODg3OTY5OTEwIiwicHJvamVjdF9pZCI6ImNiZjY5MzRjOTU2ZjAwMDY3OTllNDIwNTRmNTBjM2E2IiwidmVyIjoiMS4wLjAiLCJhdWQiOiJwcmV2aWV3LmRlbGl2ZXIua2VudGljb2Nsb3VkLmNvbSJ9.SJsYWfghbiSNOkIKEIcXatKjGr-V5u89vSgjpza3ik4';//'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJqdGkiOiI5Y2YxNzFjYTFjOWM0ODgwOGZkNzdhOTI2MzI5Njg4YSIsImlhdCI6IjE1NDE1MzMxNTciLCJleHAiOiIxODg3MTMzMTU3IiwicHJvamVjdF9pZCI6ImRiYjUwNjhjOWVkOTAwZjM3ODk4ZDNiNDZlMzFmOWVkIiwidmVyIjoiMS4wLjAiLCJhdWQiOiJwcmV2aWV3LmRlbGl2ZXIua2VudGljb2Nsb3VkLmNvbSJ9.GEvEf_9u3vZEOJGQIoi0ps_TWeC5YbEPg5gGDrTMM1Y'; +const projectId = ''; +const previewApiKey = ''; // models import { AboutUs } from './Models/AboutUs'