@everymatrix/blog-article-details 1.13.23 → 1.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- import{p as e,b as t}from"./p-68e0210a.js";(()=>{const t=import.meta.url,n={};return""!==t&&(n.resourcesUrl=new URL(".",t).href),e(n)})().then((e=>t([["p-2ce77338",[[1,"blog-article-details",{cmsEndpoint:[513,"cms-endpoint"],language:[513],userRoles:[513,"user-roles"],cmsEnv:[513,"cms-env"],handleClick:[513,"handle-click"],clientStyling:[513,"client-styling"],clientStylingUrl:[513,"client-styling-url"],showPublishingDate:[516,"show-publishing-date"],showImage:[516,"show-image"],showTitle:[516,"show-title"],showContent:[516,"show-content"],postMessageEvent:[513,"post-message-event"],postId:[514,"post-id"],intlDateTimeFormat:[1,"intl-date-time-format"],hasErrors:[32],limitStylingAppends:[32],isLoading:[32],bannerMatrixReady:[32],device:[32]},[[8,"BannerMatrixReady","handleBannerReady"]]]]]],e)));
1
+ import{p as e,b as t}from"./p-68e0210a.js";(()=>{const t=import.meta.url,s={};return""!==t&&(s.resourcesUrl=new URL(".",t).href),e(s)})().then((e=>t([["p-dff3451f",[[1,"blog-article-details",{cmsEndpoint:[513,"cms-endpoint"],language:[513],userRoles:[513,"user-roles"],cmsEnv:[513,"cms-env"],clientStyling:[513,"client-styling"],clientStylingUrl:[513,"client-styling-url"],showPublishingDate:[516,"show-publishing-date"],showImage:[516,"show-image"],showTitle:[516,"show-title"],showContent:[516,"show-content"],postMessageEvent:[513,"post-message-event"],postId:[514,"post-id"],postSlug:[513,"post-slug"],intlDateTimeFormat:[1,"intl-date-time-format"],hasErrors:[32],limitStylingAppends:[32],isLoading:[32],bannerMatrixReady:[32],device:[32]},[[8,"BannerMatrixReady","handleBannerReady"]]]]]],e)));
@@ -0,0 +1 @@
1
+ import{r as t,h as i}from"./p-68e0210a.js";const n=["ro","en","fr","ar"],e={en:{error:"Error"},ro:{error:"Eroare"},fr:{error:"Error"},ar:{error:"خطأ"}},r=class{constructor(n){t(this,n),this.language="en",this.userRoles="everyone",this.cmsEnv="stage",this.clientStyling="",this.clientStylingUrl="",this.showPublishingDate=!0,this.showImage=!0,this.showTitle=!0,this.showContent=!0,this.postMessageEvent="articleActionButton",this.intlDateTimeFormat="",this.hasErrors=!1,this.limitStylingAppends=!1,this.isLoading=!0,this.bannerMatrixReady=!1,this.device="",this.setClientStyling=()=>{let t=document.createElement("style");t.innerHTML=this.clientStyling,this.stylingContainer.prepend(t)},this.setClientStylingURL=()=>{let t=new URL(this.clientStylingUrl),i=document.createElement("style");fetch(t.href).then((t=>t.text())).then((t=>{i.innerHTML=t,setTimeout((()=>{this.stylingContainer.prepend(i)}),1)})).catch((t=>{console.log("error ",t)}))},this.renderContentConditionally=t=>-1!==(null==t?void 0:t.indexOf("<bannermatrix-banner"))?this.bannerMatrixReady?i("div",{class:"BlogContent",innerHTML:t}):null:i("div",{class:"BlogContent",innerHTML:t}),this.setImage=t=>{let i="";switch(this.device){case"mobile":i=t.sources[0].pictureSource;break;case"tablet":i=t.sources[1].pictureSource;break;case"desktop":i=t.sources[2].pictureSource}return i}}handleBannerReady(){this.bannerMatrixReady=!0}watchEndpoint(t,i){t&&t!=i&&this.cmsEndpoint&&this.getBlogArticleDetails()}connectedCallback(){this.cmsEndpoint&&this.language&&this.getBlogArticleDetails()}getBlogArticleDetails(){if(!this.postId&&!this.postSlug)throw this.hasErrors=!0,new Error("postId or postSlug parameter has to be provided!");this.isLoading=!0;let t=new URL(`${this.cmsEndpoint}/${this.language}/blog-posts/${this.postSlug||this.postId}`);t.searchParams.append("env",this.cmsEnv),t.searchParams.append("userRoles",this.userRoles),t.searchParams.append("device",(()=>{const t=(()=>{let t=window.navigator.userAgent;return t.toLowerCase().match(/android/i)?"Android":t.toLowerCase().match(/iphone/i)?"iPhone":t.toLowerCase().match(/ipad|ipod/i)?"iPad":"PC"})();if(t)return"PC"===t?"dk":"mtWeb"})()),fetch(t.href).then((t=>{if(t.status>=300)throw this.hasErrors=!0,new Error("There was an error while fetching the data");return t.json()})).then((t=>{this.blogData=t,this.isLoading=!1})).catch((t=>{this.hasErrors=!0,console.log("Error",t)})).finally((()=>this.isLoading=!1))}componentDidRender(){!this.limitStylingAppends&&this.stylingContainer&&(this.clientStyling&&this.setClientStyling(),this.clientStylingUrl&&this.setClientStylingURL(),this.limitStylingAppends=!0)}componentDidLoad(){this.detectAndAlertDeviceType()}detectAndAlertDeviceType(){this.device=function(){const t=navigator.userAgent.toLowerCase(),i=screen.availWidth,n=screen.availHeight;if(t.includes("iphone"))return"mobile";if(t.includes("android")){if(n>i&&i<800)return"mobile";if(i>n&&n<800)return"tablet"}return"desktop"}()}formatDate(t){return new Intl.DateTimeFormat(this.intlDateTimeFormat||"en-GB").format(new Date(t))}render(){var t,r,o,s,h;return this.hasErrors?i("div",{class:"BlogArticleDetails"},i("div",{class:"Title"},(()=>{const t=this.language;return e[void 0!==t&&n.includes(t)?t:"en"].error})())):this.isLoading?void 0:i("div",{ref:t=>this.stylingContainer=t},i("div",{class:"GridContainer"},this.showPublishingDate&&i("div",{class:"BlogDate"},this.formatDate(null===(t=this.blogData)||void 0===t?void 0:t.publishingDate)),this.showImage&&i("div",{class:"BlogBanner"},(null===(r=this.blogData.image)||void 0===r?void 0:r.src)?i("img",{src:this.setImage(this.blogData.image),alt:this.blogData.image.slug}):(null===(o=this.blogData.video)||void 0===o?void 0:o.sources[this.device])?i("video",{src:this.blogData.video.sources[this.device],controls:!0}):i("h1",{style:{color:"white"}},"No Image")),this.showTitle&&i("div",{class:"BlogTitle"},null===(s=this.blogData)||void 0===s?void 0:s.title),this.showContent&&this.renderContentConditionally(null===(h=this.blogData)||void 0===h?void 0:h.content)))}static get watchers(){return{cmsEndpoint:["watchEndpoint"],language:["watchEndpoint"]}}};r.style=":host {\n display: block;\n}\n\n.GridContainer {\n overflow: auto;\n margin: auto;\n width: 100%;\n padding-bottom: 30px;\n background-color: #07072A;\n display: grid;\n grid-template-rows: auto;\n grid-template-columns: 30px 60px 1fr 30px;\n gap: 10px;\n}\n.GridContainer .BlogBanner {\n grid-column: 1/5;\n grid-row: 1/3;\n}\n.GridContainer .BlogBanner img {\n width: 100%;\n height: auto;\n}\n.GridContainer .BlogDate {\n grid-column: 2/3;\n grid-row: 2/3;\n font-size: 12px;\n border-radius: 5px 5px 0 0;\n padding: 10px;\n width: fit-content;\n text-align: center;\n color: #FFF;\n background-color: #0D0D4D;\n z-index: 1;\n text-wrap: nowrap;\n}\n.GridContainer .BlogTitle {\n grid-column: 2/4;\n font-size: 24px;\n color: #FFF;\n}\n.GridContainer .BlogContent {\n grid-column: 2/4;\n font-size: 14px;\n color: #FFF;\n}\n\n@container (max-width: 475px) {\n .GridContainer {\n font-size: 12px;\n }\n}";export{r as blog_article_details}
@@ -70,7 +70,7 @@ const getDevicePlatform = () => {
70
70
  }
71
71
  };
72
72
 
73
- const blogArticleDetailsCss = ":host {\n display: block;\n}\n\n.GridContainer {\n overflow: auto;\n margin: auto;\n width: 100%;\n padding-bottom: 30px;\n background-color: #07072A;\n display: grid;\n grid-template-rows: auto;\n grid-template-columns: 30px 60px 1fr 30px;\n gap: 10px;\n}\n.GridContainer .BlogBanner {\n grid-column: 1/5;\n grid-row: 1/3;\n}\n.GridContainer .BlogBanner img {\n width: 100%;\n height: auto;\n}\n.GridContainer .BlogDate {\n grid-column: 2/3;\n grid-row: 2/3;\n font-size: 12px;\n border-radius: 5px 5px 0 0;\n padding: 10px;\n width: fit-content;\n text-align: center;\n color: #FFF;\n background-color: #0D0D4D;\n z-index: 1;\n}\n.GridContainer .BlogTitle {\n grid-column: 2/4;\n font-size: 24px;\n color: #FFF;\n}\n.GridContainer .BlogContent {\n grid-column: 2/4;\n font-size: 14px;\n color: #FFF;\n}\n\n@container (max-width: 475px) {\n .GridContainer {\n font-size: 12px;\n }\n}";
73
+ const blogArticleDetailsCss = ":host {\n display: block;\n}\n\n.GridContainer {\n overflow: auto;\n margin: auto;\n width: 100%;\n padding-bottom: 30px;\n background-color: #07072A;\n display: grid;\n grid-template-rows: auto;\n grid-template-columns: 30px 60px 1fr 30px;\n gap: 10px;\n}\n.GridContainer .BlogBanner {\n grid-column: 1/5;\n grid-row: 1/3;\n}\n.GridContainer .BlogBanner img {\n width: 100%;\n height: auto;\n}\n.GridContainer .BlogDate {\n grid-column: 2/3;\n grid-row: 2/3;\n font-size: 12px;\n border-radius: 5px 5px 0 0;\n padding: 10px;\n width: fit-content;\n text-align: center;\n color: #FFF;\n background-color: #0D0D4D;\n z-index: 1;\n text-wrap: nowrap;\n}\n.GridContainer .BlogTitle {\n grid-column: 2/4;\n font-size: 24px;\n color: #FFF;\n}\n.GridContainer .BlogContent {\n grid-column: 2/4;\n font-size: 14px;\n color: #FFF;\n}\n\n@container (max-width: 475px) {\n .GridContainer {\n font-size: 12px;\n }\n}";
74
74
 
75
75
  const BlogArticleDetails = class {
76
76
  constructor(hostRef) {
@@ -152,6 +152,21 @@ const BlogArticleDetails = class {
152
152
  }
153
153
  return null;
154
154
  };
155
+ this.setImage = (image) => {
156
+ let source = '';
157
+ switch (this.device) {
158
+ case 'mobile':
159
+ source = image.sources[0].pictureSource;
160
+ break;
161
+ case 'tablet':
162
+ source = image.sources[1].pictureSource;
163
+ break;
164
+ case 'desktop':
165
+ source = image.sources[2].pictureSource;
166
+ break;
167
+ }
168
+ return source;
169
+ };
155
170
  }
156
171
  // Rerender when bannermatrix has finished loaded. Issue when bannermatrix passed as content from CMS.
157
172
  handleBannerReady() {
@@ -168,12 +183,12 @@ const BlogArticleDetails = class {
168
183
  }
169
184
  }
170
185
  getBlogArticleDetails() {
171
- if (!this.postId && isNaN(this.postId)) {
186
+ if (!this.postId && !this.postSlug) {
172
187
  this.hasErrors = true;
173
- throw new Error('The postId parameter is missing!');
188
+ throw new Error('postId or postSlug parameter has to be provided!');
174
189
  }
175
190
  this.isLoading = true;
176
- let url = new URL(`${this.cmsEndpoint}/${this.language}/blog-posts/${this.postId}`);
191
+ let url = new URL(`${this.cmsEndpoint}/${this.language}/blog-posts/${this.postSlug || this.postId}`);
177
192
  url.searchParams.append('env', this.cmsEnv);
178
193
  url.searchParams.append('userRoles', this.userRoles);
179
194
  url.searchParams.append('device', getDevicePlatform());
@@ -187,7 +202,6 @@ const BlogArticleDetails = class {
187
202
  })
188
203
  .then((blogContent) => {
189
204
  this.blogData = blogContent;
190
- this.blogData.publishingDate = new Date(this.blogData.publishingDate).toLocaleDateString();
191
205
  this.isLoading = false;
192
206
  })
193
207
  .catch((err) => {
@@ -214,7 +228,7 @@ const BlogArticleDetails = class {
214
228
  this.device = checkDeviceType();
215
229
  }
216
230
  formatDate(dateString) {
217
- return new Intl.DateTimeFormat(this.intlDateTimeFormat).format(new Date(dateString));
231
+ return new Intl.DateTimeFormat(this.intlDateTimeFormat || 'en-GB').format(new Date(dateString));
218
232
  }
219
233
  render() {
220
234
  var _a, _b, _c, _d, _e;
@@ -223,7 +237,7 @@ const BlogArticleDetails = class {
223
237
  }
224
238
  if (!this.isLoading) {
225
239
  return (index.h("div", { ref: el => this.stylingContainer = el }, index.h("div", { class: "GridContainer" }, this.showPublishingDate &&
226
- index.h("div", { class: "BlogDate" }, this.formatDate((_a = this.blogData) === null || _a === void 0 ? void 0 : _a.publishingDate)), this.showImage && (index.h("div", { class: "BlogBanner" }, ((_b = this.blogData.image) === null || _b === void 0 ? void 0 : _b.src) ? (index.h("img", { src: this.blogData.image.src, alt: this.blogData.image.src })) : (((_c = this.blogData.video) === null || _c === void 0 ? void 0 : _c.sources[this.device]) ? (index.h("video", { src: this.blogData.video.sources[this.device], controls: true })) : (index.h("h1", { style: { color: "white" } }, "No Image"))))), this.showTitle &&
240
+ index.h("div", { class: "BlogDate" }, this.formatDate((_a = this.blogData) === null || _a === void 0 ? void 0 : _a.publishingDate)), this.showImage && (index.h("div", { class: "BlogBanner" }, ((_b = this.blogData.image) === null || _b === void 0 ? void 0 : _b.src) ? (index.h("img", { src: this.setImage(this.blogData.image), alt: this.blogData.image.slug })) : (((_c = this.blogData.video) === null || _c === void 0 ? void 0 : _c.sources[this.device]) ? (index.h("video", { src: this.blogData.video.sources[this.device], controls: true })) : (index.h("h1", { style: { color: "white" } }, "No Image"))))), this.showTitle &&
227
241
  index.h("div", { class: "BlogTitle" }, (_d = this.blogData) === null || _d === void 0 ? void 0 : _d.title), this.showContent && this.renderContentConditionally((_e = this.blogData) === null || _e === void 0 ? void 0 : _e.content))));
228
242
  }
229
243
  }
@@ -15,5 +15,5 @@ const patchBrowser = () => {
15
15
  };
16
16
 
17
17
  patchBrowser().then(options => {
18
- return index.bootstrapLazy([["blog-article-details.cjs",[[1,"blog-article-details",{"cmsEndpoint":[513,"cms-endpoint"],"language":[513],"userRoles":[513,"user-roles"],"cmsEnv":[513,"cms-env"],"handleClick":[513,"handle-click"],"clientStyling":[513,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"showPublishingDate":[516,"show-publishing-date"],"showImage":[516,"show-image"],"showTitle":[516,"show-title"],"showContent":[516,"show-content"],"postMessageEvent":[513,"post-message-event"],"postId":[514,"post-id"],"intlDateTimeFormat":[1,"intl-date-time-format"],"hasErrors":[32],"limitStylingAppends":[32],"isLoading":[32],"bannerMatrixReady":[32],"device":[32]},[[8,"BannerMatrixReady","handleBannerReady"]]]]]], options);
18
+ return index.bootstrapLazy([["blog-article-details.cjs",[[1,"blog-article-details",{"cmsEndpoint":[513,"cms-endpoint"],"language":[513],"userRoles":[513,"user-roles"],"cmsEnv":[513,"cms-env"],"clientStyling":[513,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"showPublishingDate":[516,"show-publishing-date"],"showImage":[516,"show-image"],"showTitle":[516,"show-title"],"showContent":[516,"show-content"],"postMessageEvent":[513,"post-message-event"],"postId":[514,"post-id"],"postSlug":[513,"post-slug"],"intlDateTimeFormat":[1,"intl-date-time-format"],"hasErrors":[32],"limitStylingAppends":[32],"isLoading":[32],"bannerMatrixReady":[32],"device":[32]},[[8,"BannerMatrixReady","handleBannerReady"]]]]]], options);
19
19
  });
@@ -14,7 +14,7 @@ const patchEsm = () => {
14
14
  const defineCustomElements = (win, options) => {
15
15
  if (typeof window === 'undefined') return Promise.resolve();
16
16
  return patchEsm().then(() => {
17
- return index.bootstrapLazy([["blog-article-details.cjs",[[1,"blog-article-details",{"cmsEndpoint":[513,"cms-endpoint"],"language":[513],"userRoles":[513,"user-roles"],"cmsEnv":[513,"cms-env"],"handleClick":[513,"handle-click"],"clientStyling":[513,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"showPublishingDate":[516,"show-publishing-date"],"showImage":[516,"show-image"],"showTitle":[516,"show-title"],"showContent":[516,"show-content"],"postMessageEvent":[513,"post-message-event"],"postId":[514,"post-id"],"intlDateTimeFormat":[1,"intl-date-time-format"],"hasErrors":[32],"limitStylingAppends":[32],"isLoading":[32],"bannerMatrixReady":[32],"device":[32]},[[8,"BannerMatrixReady","handleBannerReady"]]]]]], options);
17
+ return index.bootstrapLazy([["blog-article-details.cjs",[[1,"blog-article-details",{"cmsEndpoint":[513,"cms-endpoint"],"language":[513],"userRoles":[513,"user-roles"],"cmsEnv":[513,"cms-env"],"clientStyling":[513,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"showPublishingDate":[516,"show-publishing-date"],"showImage":[516,"show-image"],"showTitle":[516,"show-title"],"showContent":[516,"show-content"],"postMessageEvent":[513,"post-message-event"],"postId":[514,"post-id"],"postSlug":[513,"post-slug"],"intlDateTimeFormat":[1,"intl-date-time-format"],"hasErrors":[32],"limitStylingAppends":[32],"isLoading":[32],"bannerMatrixReady":[32],"device":[32]},[[8,"BannerMatrixReady","handleBannerReady"]]]]]], options);
18
18
  });
19
19
  };
20
20
 
@@ -32,6 +32,7 @@
32
32
  color: #FFF;
33
33
  background-color: #0D0D4D;
34
34
  z-index: 1;
35
+ text-wrap: nowrap;
35
36
  }
36
37
  .GridContainer .BlogTitle {
37
38
  grid-column: 2/4;
@@ -80,6 +80,21 @@ export class BlogArticleDetails {
80
80
  }
81
81
  return null;
82
82
  };
83
+ this.setImage = (image) => {
84
+ let source = '';
85
+ switch (this.device) {
86
+ case 'mobile':
87
+ source = image.sources[0].pictureSource;
88
+ break;
89
+ case 'tablet':
90
+ source = image.sources[1].pictureSource;
91
+ break;
92
+ case 'desktop':
93
+ source = image.sources[2].pictureSource;
94
+ break;
95
+ }
96
+ return source;
97
+ };
83
98
  }
84
99
  // Rerender when bannermatrix has finished loaded. Issue when bannermatrix passed as content from CMS.
85
100
  handleBannerReady() {
@@ -96,12 +111,12 @@ export class BlogArticleDetails {
96
111
  }
97
112
  }
98
113
  getBlogArticleDetails() {
99
- if (!this.postId && isNaN(this.postId)) {
114
+ if (!this.postId && !this.postSlug) {
100
115
  this.hasErrors = true;
101
- throw new Error('The postId parameter is missing!');
116
+ throw new Error('postId or postSlug parameter has to be provided!');
102
117
  }
103
118
  this.isLoading = true;
104
- let url = new URL(`${this.cmsEndpoint}/${this.language}/blog-posts/${this.postId}`);
119
+ let url = new URL(`${this.cmsEndpoint}/${this.language}/blog-posts/${this.postSlug || this.postId}`);
105
120
  url.searchParams.append('env', this.cmsEnv);
106
121
  url.searchParams.append('userRoles', this.userRoles);
107
122
  url.searchParams.append('device', getDevicePlatform());
@@ -115,7 +130,6 @@ export class BlogArticleDetails {
115
130
  })
116
131
  .then((blogContent) => {
117
132
  this.blogData = blogContent;
118
- this.blogData.publishingDate = new Date(this.blogData.publishingDate).toLocaleDateString();
119
133
  this.isLoading = false;
120
134
  })
121
135
  .catch((err) => {
@@ -142,7 +156,7 @@ export class BlogArticleDetails {
142
156
  this.device = checkDeviceType();
143
157
  }
144
158
  formatDate(dateString) {
145
- return new Intl.DateTimeFormat(this.intlDateTimeFormat).format(new Date(dateString));
159
+ return new Intl.DateTimeFormat(this.intlDateTimeFormat || 'en-GB').format(new Date(dateString));
146
160
  }
147
161
  render() {
148
162
  var _a, _b, _c, _d, _e;
@@ -155,7 +169,7 @@ export class BlogArticleDetails {
155
169
  h("div", { class: "GridContainer" },
156
170
  this.showPublishingDate &&
157
171
  h("div", { class: "BlogDate" }, this.formatDate((_a = this.blogData) === null || _a === void 0 ? void 0 : _a.publishingDate)),
158
- this.showImage && (h("div", { class: "BlogBanner" }, ((_b = this.blogData.image) === null || _b === void 0 ? void 0 : _b.src) ? (h("img", { src: this.blogData.image.src, alt: this.blogData.image.src })) : (((_c = this.blogData.video) === null || _c === void 0 ? void 0 : _c.sources[this.device]) ? (h("video", { src: this.blogData.video.sources[this.device], controls: true })) : (h("h1", { style: { color: "white" } }, "No Image"))))),
172
+ this.showImage && (h("div", { class: "BlogBanner" }, ((_b = this.blogData.image) === null || _b === void 0 ? void 0 : _b.src) ? (h("img", { src: this.setImage(this.blogData.image), alt: this.blogData.image.slug })) : (((_c = this.blogData.video) === null || _c === void 0 ? void 0 : _c.sources[this.device]) ? (h("video", { src: this.blogData.video.sources[this.device], controls: true })) : (h("h1", { style: { color: "white" } }, "No Image"))))),
159
173
  this.showTitle &&
160
174
  h("div", { class: "BlogTitle" }, (_d = this.blogData) === null || _d === void 0 ? void 0 : _d.title),
161
175
  this.showContent && this.renderContentConditionally((_e = this.blogData) === null || _e === void 0 ? void 0 : _e.content))));
@@ -241,23 +255,6 @@ export class BlogArticleDetails {
241
255
  "reflect": true,
242
256
  "defaultValue": "'stage'"
243
257
  },
244
- "handleClick": {
245
- "type": "string",
246
- "mutable": false,
247
- "complexType": {
248
- "original": "string",
249
- "resolved": "string",
250
- "references": {}
251
- },
252
- "required": false,
253
- "optional": false,
254
- "docs": {
255
- "tags": [],
256
- "text": "Handle when you click on show more button"
257
- },
258
- "attribute": "handle-click",
259
- "reflect": true
260
- },
261
258
  "clientStyling": {
262
259
  "type": "string",
263
260
  "mutable": false,
@@ -392,7 +389,7 @@ export class BlogArticleDetails {
392
389
  "resolved": "number",
393
390
  "references": {}
394
391
  },
395
- "required": true,
392
+ "required": false,
396
393
  "optional": false,
397
394
  "docs": {
398
395
  "tags": [],
@@ -401,6 +398,23 @@ export class BlogArticleDetails {
401
398
  "attribute": "post-id",
402
399
  "reflect": true
403
400
  },
401
+ "postSlug": {
402
+ "type": "string",
403
+ "mutable": false,
404
+ "complexType": {
405
+ "original": "string",
406
+ "resolved": "string",
407
+ "references": {}
408
+ },
409
+ "required": false,
410
+ "optional": false,
411
+ "docs": {
412
+ "tags": [],
413
+ "text": "Slug of post"
414
+ },
415
+ "attribute": "post-slug",
416
+ "reflect": true
417
+ },
404
418
  "intlDateTimeFormat": {
405
419
  "type": "string",
406
420
  "mutable": false,
@@ -66,7 +66,7 @@ const getDevicePlatform = () => {
66
66
  }
67
67
  };
68
68
 
69
- const blogArticleDetailsCss = ":host {\n display: block;\n}\n\n.GridContainer {\n overflow: auto;\n margin: auto;\n width: 100%;\n padding-bottom: 30px;\n background-color: #07072A;\n display: grid;\n grid-template-rows: auto;\n grid-template-columns: 30px 60px 1fr 30px;\n gap: 10px;\n}\n.GridContainer .BlogBanner {\n grid-column: 1/5;\n grid-row: 1/3;\n}\n.GridContainer .BlogBanner img {\n width: 100%;\n height: auto;\n}\n.GridContainer .BlogDate {\n grid-column: 2/3;\n grid-row: 2/3;\n font-size: 12px;\n border-radius: 5px 5px 0 0;\n padding: 10px;\n width: fit-content;\n text-align: center;\n color: #FFF;\n background-color: #0D0D4D;\n z-index: 1;\n}\n.GridContainer .BlogTitle {\n grid-column: 2/4;\n font-size: 24px;\n color: #FFF;\n}\n.GridContainer .BlogContent {\n grid-column: 2/4;\n font-size: 14px;\n color: #FFF;\n}\n\n@container (max-width: 475px) {\n .GridContainer {\n font-size: 12px;\n }\n}";
69
+ const blogArticleDetailsCss = ":host {\n display: block;\n}\n\n.GridContainer {\n overflow: auto;\n margin: auto;\n width: 100%;\n padding-bottom: 30px;\n background-color: #07072A;\n display: grid;\n grid-template-rows: auto;\n grid-template-columns: 30px 60px 1fr 30px;\n gap: 10px;\n}\n.GridContainer .BlogBanner {\n grid-column: 1/5;\n grid-row: 1/3;\n}\n.GridContainer .BlogBanner img {\n width: 100%;\n height: auto;\n}\n.GridContainer .BlogDate {\n grid-column: 2/3;\n grid-row: 2/3;\n font-size: 12px;\n border-radius: 5px 5px 0 0;\n padding: 10px;\n width: fit-content;\n text-align: center;\n color: #FFF;\n background-color: #0D0D4D;\n z-index: 1;\n text-wrap: nowrap;\n}\n.GridContainer .BlogTitle {\n grid-column: 2/4;\n font-size: 24px;\n color: #FFF;\n}\n.GridContainer .BlogContent {\n grid-column: 2/4;\n font-size: 14px;\n color: #FFF;\n}\n\n@container (max-width: 475px) {\n .GridContainer {\n font-size: 12px;\n }\n}";
70
70
 
71
71
  const BlogArticleDetails$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
72
72
  constructor() {
@@ -150,6 +150,21 @@ const BlogArticleDetails$1 = /*@__PURE__*/ proxyCustomElement(class extends HTML
150
150
  }
151
151
  return null;
152
152
  };
153
+ this.setImage = (image) => {
154
+ let source = '';
155
+ switch (this.device) {
156
+ case 'mobile':
157
+ source = image.sources[0].pictureSource;
158
+ break;
159
+ case 'tablet':
160
+ source = image.sources[1].pictureSource;
161
+ break;
162
+ case 'desktop':
163
+ source = image.sources[2].pictureSource;
164
+ break;
165
+ }
166
+ return source;
167
+ };
153
168
  }
154
169
  // Rerender when bannermatrix has finished loaded. Issue when bannermatrix passed as content from CMS.
155
170
  handleBannerReady() {
@@ -166,12 +181,12 @@ const BlogArticleDetails$1 = /*@__PURE__*/ proxyCustomElement(class extends HTML
166
181
  }
167
182
  }
168
183
  getBlogArticleDetails() {
169
- if (!this.postId && isNaN(this.postId)) {
184
+ if (!this.postId && !this.postSlug) {
170
185
  this.hasErrors = true;
171
- throw new Error('The postId parameter is missing!');
186
+ throw new Error('postId or postSlug parameter has to be provided!');
172
187
  }
173
188
  this.isLoading = true;
174
- let url = new URL(`${this.cmsEndpoint}/${this.language}/blog-posts/${this.postId}`);
189
+ let url = new URL(`${this.cmsEndpoint}/${this.language}/blog-posts/${this.postSlug || this.postId}`);
175
190
  url.searchParams.append('env', this.cmsEnv);
176
191
  url.searchParams.append('userRoles', this.userRoles);
177
192
  url.searchParams.append('device', getDevicePlatform());
@@ -185,7 +200,6 @@ const BlogArticleDetails$1 = /*@__PURE__*/ proxyCustomElement(class extends HTML
185
200
  })
186
201
  .then((blogContent) => {
187
202
  this.blogData = blogContent;
188
- this.blogData.publishingDate = new Date(this.blogData.publishingDate).toLocaleDateString();
189
203
  this.isLoading = false;
190
204
  })
191
205
  .catch((err) => {
@@ -212,7 +226,7 @@ const BlogArticleDetails$1 = /*@__PURE__*/ proxyCustomElement(class extends HTML
212
226
  this.device = checkDeviceType();
213
227
  }
214
228
  formatDate(dateString) {
215
- return new Intl.DateTimeFormat(this.intlDateTimeFormat).format(new Date(dateString));
229
+ return new Intl.DateTimeFormat(this.intlDateTimeFormat || 'en-GB').format(new Date(dateString));
216
230
  }
217
231
  render() {
218
232
  var _a, _b, _c, _d, _e;
@@ -221,7 +235,7 @@ const BlogArticleDetails$1 = /*@__PURE__*/ proxyCustomElement(class extends HTML
221
235
  }
222
236
  if (!this.isLoading) {
223
237
  return (h("div", { ref: el => this.stylingContainer = el }, h("div", { class: "GridContainer" }, this.showPublishingDate &&
224
- h("div", { class: "BlogDate" }, this.formatDate((_a = this.blogData) === null || _a === void 0 ? void 0 : _a.publishingDate)), this.showImage && (h("div", { class: "BlogBanner" }, ((_b = this.blogData.image) === null || _b === void 0 ? void 0 : _b.src) ? (h("img", { src: this.blogData.image.src, alt: this.blogData.image.src })) : (((_c = this.blogData.video) === null || _c === void 0 ? void 0 : _c.sources[this.device]) ? (h("video", { src: this.blogData.video.sources[this.device], controls: true })) : (h("h1", { style: { color: "white" } }, "No Image"))))), this.showTitle &&
238
+ h("div", { class: "BlogDate" }, this.formatDate((_a = this.blogData) === null || _a === void 0 ? void 0 : _a.publishingDate)), this.showImage && (h("div", { class: "BlogBanner" }, ((_b = this.blogData.image) === null || _b === void 0 ? void 0 : _b.src) ? (h("img", { src: this.setImage(this.blogData.image), alt: this.blogData.image.slug })) : (((_c = this.blogData.video) === null || _c === void 0 ? void 0 : _c.sources[this.device]) ? (h("video", { src: this.blogData.video.sources[this.device], controls: true })) : (h("h1", { style: { color: "white" } }, "No Image"))))), this.showTitle &&
225
239
  h("div", { class: "BlogTitle" }, (_d = this.blogData) === null || _d === void 0 ? void 0 : _d.title), this.showContent && this.renderContentConditionally((_e = this.blogData) === null || _e === void 0 ? void 0 : _e.content))));
226
240
  }
227
241
  }
@@ -235,7 +249,6 @@ const BlogArticleDetails$1 = /*@__PURE__*/ proxyCustomElement(class extends HTML
235
249
  "language": [513],
236
250
  "userRoles": [513, "user-roles"],
237
251
  "cmsEnv": [513, "cms-env"],
238
- "handleClick": [513, "handle-click"],
239
252
  "clientStyling": [513, "client-styling"],
240
253
  "clientStylingUrl": [513, "client-styling-url"],
241
254
  "showPublishingDate": [516, "show-publishing-date"],
@@ -244,6 +257,7 @@ const BlogArticleDetails$1 = /*@__PURE__*/ proxyCustomElement(class extends HTML
244
257
  "showContent": [516, "show-content"],
245
258
  "postMessageEvent": [513, "post-message-event"],
246
259
  "postId": [514, "post-id"],
260
+ "postSlug": [513, "post-slug"],
247
261
  "intlDateTimeFormat": [1, "intl-date-time-format"],
248
262
  "hasErrors": [32],
249
263
  "limitStylingAppends": [32],
@@ -66,7 +66,7 @@ const getDevicePlatform = () => {
66
66
  }
67
67
  };
68
68
 
69
- const blogArticleDetailsCss = ":host {\n display: block;\n}\n\n.GridContainer {\n overflow: auto;\n margin: auto;\n width: 100%;\n padding-bottom: 30px;\n background-color: #07072A;\n display: grid;\n grid-template-rows: auto;\n grid-template-columns: 30px 60px 1fr 30px;\n gap: 10px;\n}\n.GridContainer .BlogBanner {\n grid-column: 1/5;\n grid-row: 1/3;\n}\n.GridContainer .BlogBanner img {\n width: 100%;\n height: auto;\n}\n.GridContainer .BlogDate {\n grid-column: 2/3;\n grid-row: 2/3;\n font-size: 12px;\n border-radius: 5px 5px 0 0;\n padding: 10px;\n width: fit-content;\n text-align: center;\n color: #FFF;\n background-color: #0D0D4D;\n z-index: 1;\n}\n.GridContainer .BlogTitle {\n grid-column: 2/4;\n font-size: 24px;\n color: #FFF;\n}\n.GridContainer .BlogContent {\n grid-column: 2/4;\n font-size: 14px;\n color: #FFF;\n}\n\n@container (max-width: 475px) {\n .GridContainer {\n font-size: 12px;\n }\n}";
69
+ const blogArticleDetailsCss = ":host {\n display: block;\n}\n\n.GridContainer {\n overflow: auto;\n margin: auto;\n width: 100%;\n padding-bottom: 30px;\n background-color: #07072A;\n display: grid;\n grid-template-rows: auto;\n grid-template-columns: 30px 60px 1fr 30px;\n gap: 10px;\n}\n.GridContainer .BlogBanner {\n grid-column: 1/5;\n grid-row: 1/3;\n}\n.GridContainer .BlogBanner img {\n width: 100%;\n height: auto;\n}\n.GridContainer .BlogDate {\n grid-column: 2/3;\n grid-row: 2/3;\n font-size: 12px;\n border-radius: 5px 5px 0 0;\n padding: 10px;\n width: fit-content;\n text-align: center;\n color: #FFF;\n background-color: #0D0D4D;\n z-index: 1;\n text-wrap: nowrap;\n}\n.GridContainer .BlogTitle {\n grid-column: 2/4;\n font-size: 24px;\n color: #FFF;\n}\n.GridContainer .BlogContent {\n grid-column: 2/4;\n font-size: 14px;\n color: #FFF;\n}\n\n@container (max-width: 475px) {\n .GridContainer {\n font-size: 12px;\n }\n}";
70
70
 
71
71
  const BlogArticleDetails = class {
72
72
  constructor(hostRef) {
@@ -148,6 +148,21 @@ const BlogArticleDetails = class {
148
148
  }
149
149
  return null;
150
150
  };
151
+ this.setImage = (image) => {
152
+ let source = '';
153
+ switch (this.device) {
154
+ case 'mobile':
155
+ source = image.sources[0].pictureSource;
156
+ break;
157
+ case 'tablet':
158
+ source = image.sources[1].pictureSource;
159
+ break;
160
+ case 'desktop':
161
+ source = image.sources[2].pictureSource;
162
+ break;
163
+ }
164
+ return source;
165
+ };
151
166
  }
152
167
  // Rerender when bannermatrix has finished loaded. Issue when bannermatrix passed as content from CMS.
153
168
  handleBannerReady() {
@@ -164,12 +179,12 @@ const BlogArticleDetails = class {
164
179
  }
165
180
  }
166
181
  getBlogArticleDetails() {
167
- if (!this.postId && isNaN(this.postId)) {
182
+ if (!this.postId && !this.postSlug) {
168
183
  this.hasErrors = true;
169
- throw new Error('The postId parameter is missing!');
184
+ throw new Error('postId or postSlug parameter has to be provided!');
170
185
  }
171
186
  this.isLoading = true;
172
- let url = new URL(`${this.cmsEndpoint}/${this.language}/blog-posts/${this.postId}`);
187
+ let url = new URL(`${this.cmsEndpoint}/${this.language}/blog-posts/${this.postSlug || this.postId}`);
173
188
  url.searchParams.append('env', this.cmsEnv);
174
189
  url.searchParams.append('userRoles', this.userRoles);
175
190
  url.searchParams.append('device', getDevicePlatform());
@@ -183,7 +198,6 @@ const BlogArticleDetails = class {
183
198
  })
184
199
  .then((blogContent) => {
185
200
  this.blogData = blogContent;
186
- this.blogData.publishingDate = new Date(this.blogData.publishingDate).toLocaleDateString();
187
201
  this.isLoading = false;
188
202
  })
189
203
  .catch((err) => {
@@ -210,7 +224,7 @@ const BlogArticleDetails = class {
210
224
  this.device = checkDeviceType();
211
225
  }
212
226
  formatDate(dateString) {
213
- return new Intl.DateTimeFormat(this.intlDateTimeFormat).format(new Date(dateString));
227
+ return new Intl.DateTimeFormat(this.intlDateTimeFormat || 'en-GB').format(new Date(dateString));
214
228
  }
215
229
  render() {
216
230
  var _a, _b, _c, _d, _e;
@@ -219,7 +233,7 @@ const BlogArticleDetails = class {
219
233
  }
220
234
  if (!this.isLoading) {
221
235
  return (h("div", { ref: el => this.stylingContainer = el }, h("div", { class: "GridContainer" }, this.showPublishingDate &&
222
- h("div", { class: "BlogDate" }, this.formatDate((_a = this.blogData) === null || _a === void 0 ? void 0 : _a.publishingDate)), this.showImage && (h("div", { class: "BlogBanner" }, ((_b = this.blogData.image) === null || _b === void 0 ? void 0 : _b.src) ? (h("img", { src: this.blogData.image.src, alt: this.blogData.image.src })) : (((_c = this.blogData.video) === null || _c === void 0 ? void 0 : _c.sources[this.device]) ? (h("video", { src: this.blogData.video.sources[this.device], controls: true })) : (h("h1", { style: { color: "white" } }, "No Image"))))), this.showTitle &&
236
+ h("div", { class: "BlogDate" }, this.formatDate((_a = this.blogData) === null || _a === void 0 ? void 0 : _a.publishingDate)), this.showImage && (h("div", { class: "BlogBanner" }, ((_b = this.blogData.image) === null || _b === void 0 ? void 0 : _b.src) ? (h("img", { src: this.setImage(this.blogData.image), alt: this.blogData.image.slug })) : (((_c = this.blogData.video) === null || _c === void 0 ? void 0 : _c.sources[this.device]) ? (h("video", { src: this.blogData.video.sources[this.device], controls: true })) : (h("h1", { style: { color: "white" } }, "No Image"))))), this.showTitle &&
223
237
  h("div", { class: "BlogTitle" }, (_d = this.blogData) === null || _d === void 0 ? void 0 : _d.title), this.showContent && this.renderContentConditionally((_e = this.blogData) === null || _e === void 0 ? void 0 : _e.content))));
224
238
  }
225
239
  }
@@ -13,5 +13,5 @@ const patchBrowser = () => {
13
13
  };
14
14
 
15
15
  patchBrowser().then(options => {
16
- return bootstrapLazy([["blog-article-details",[[1,"blog-article-details",{"cmsEndpoint":[513,"cms-endpoint"],"language":[513],"userRoles":[513,"user-roles"],"cmsEnv":[513,"cms-env"],"handleClick":[513,"handle-click"],"clientStyling":[513,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"showPublishingDate":[516,"show-publishing-date"],"showImage":[516,"show-image"],"showTitle":[516,"show-title"],"showContent":[516,"show-content"],"postMessageEvent":[513,"post-message-event"],"postId":[514,"post-id"],"intlDateTimeFormat":[1,"intl-date-time-format"],"hasErrors":[32],"limitStylingAppends":[32],"isLoading":[32],"bannerMatrixReady":[32],"device":[32]},[[8,"BannerMatrixReady","handleBannerReady"]]]]]], options);
16
+ return bootstrapLazy([["blog-article-details",[[1,"blog-article-details",{"cmsEndpoint":[513,"cms-endpoint"],"language":[513],"userRoles":[513,"user-roles"],"cmsEnv":[513,"cms-env"],"clientStyling":[513,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"showPublishingDate":[516,"show-publishing-date"],"showImage":[516,"show-image"],"showTitle":[516,"show-title"],"showContent":[516,"show-content"],"postMessageEvent":[513,"post-message-event"],"postId":[514,"post-id"],"postSlug":[513,"post-slug"],"intlDateTimeFormat":[1,"intl-date-time-format"],"hasErrors":[32],"limitStylingAppends":[32],"isLoading":[32],"bannerMatrixReady":[32],"device":[32]},[[8,"BannerMatrixReady","handleBannerReady"]]]]]], options);
17
17
  });
@@ -10,7 +10,7 @@ const patchEsm = () => {
10
10
  const defineCustomElements = (win, options) => {
11
11
  if (typeof window === 'undefined') return Promise.resolve();
12
12
  return patchEsm().then(() => {
13
- return bootstrapLazy([["blog-article-details",[[1,"blog-article-details",{"cmsEndpoint":[513,"cms-endpoint"],"language":[513],"userRoles":[513,"user-roles"],"cmsEnv":[513,"cms-env"],"handleClick":[513,"handle-click"],"clientStyling":[513,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"showPublishingDate":[516,"show-publishing-date"],"showImage":[516,"show-image"],"showTitle":[516,"show-title"],"showContent":[516,"show-content"],"postMessageEvent":[513,"post-message-event"],"postId":[514,"post-id"],"intlDateTimeFormat":[1,"intl-date-time-format"],"hasErrors":[32],"limitStylingAppends":[32],"isLoading":[32],"bannerMatrixReady":[32],"device":[32]},[[8,"BannerMatrixReady","handleBannerReady"]]]]]], options);
13
+ return bootstrapLazy([["blog-article-details",[[1,"blog-article-details",{"cmsEndpoint":[513,"cms-endpoint"],"language":[513],"userRoles":[513,"user-roles"],"cmsEnv":[513,"cms-env"],"clientStyling":[513,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"showPublishingDate":[516,"show-publishing-date"],"showImage":[516,"show-image"],"showTitle":[516,"show-title"],"showContent":[516,"show-content"],"postMessageEvent":[513,"post-message-event"],"postId":[514,"post-id"],"postSlug":[513,"post-slug"],"intlDateTimeFormat":[1,"intl-date-time-format"],"hasErrors":[32],"limitStylingAppends":[32],"isLoading":[32],"bannerMatrixReady":[32],"device":[32]},[[8,"BannerMatrixReady","handleBannerReady"]]]]]], options);
14
14
  });
15
15
  };
16
16
 
@@ -0,0 +1,2 @@
1
+ import { Config } from '../../../../../../../../../../../stencil-public-runtime';
2
+ export declare const config: Config;
@@ -15,10 +15,6 @@ export declare class BlogArticleDetails {
15
15
  * CMS Endpoint stage
16
16
  */
17
17
  cmsEnv: string;
18
- /**
19
- * Handle when you click on show more button
20
- */
21
- handleClick: string;
22
18
  /**
23
19
  * Client custom styling via string
24
20
  */
@@ -51,6 +47,10 @@ export declare class BlogArticleDetails {
51
47
  * Showing post ID parameter
52
48
  */
53
49
  postId: number;
50
+ /**
51
+ * Slug of post
52
+ */
53
+ postSlug: string;
54
54
  /**
55
55
  * Intl date format
56
56
  */
@@ -73,5 +73,6 @@ export declare class BlogArticleDetails {
73
73
  setClientStylingURL: () => void;
74
74
  formatDate(dateString: any): string;
75
75
  renderContentConditionally: (content: string) => HTMLElement;
76
+ setImage: (image: any) => string;
76
77
  render(): void;
77
78
  }
@@ -23,10 +23,6 @@ export namespace Components {
23
23
  * CMS Endpoint stage
24
24
  */
25
25
  "cmsEnv": string;
26
- /**
27
- * Handle when you click on show more button
28
- */
29
- "handleClick": string;
30
26
  /**
31
27
  * Intl date format
32
28
  */
@@ -43,6 +39,10 @@ export namespace Components {
43
39
  * Event name to be sent when the button is clicked
44
40
  */
45
41
  "postMessageEvent": string;
42
+ /**
43
+ * Slug of post
44
+ */
45
+ "postSlug": string;
46
46
  /**
47
47
  * Property used to display the description
48
48
  */
@@ -94,10 +94,6 @@ declare namespace LocalJSX {
94
94
  * CMS Endpoint stage
95
95
  */
96
96
  "cmsEnv"?: string;
97
- /**
98
- * Handle when you click on show more button
99
- */
100
- "handleClick"?: string;
101
97
  /**
102
98
  * Intl date format
103
99
  */
@@ -109,11 +105,15 @@ declare namespace LocalJSX {
109
105
  /**
110
106
  * Showing post ID parameter
111
107
  */
112
- "postId": number;
108
+ "postId"?: number;
113
109
  /**
114
110
  * Event name to be sent when the button is clicked
115
111
  */
116
112
  "postMessageEvent"?: string;
113
+ /**
114
+ * Slug of post
115
+ */
116
+ "postSlug"?: string;
117
117
  /**
118
118
  * Property used to display the description
119
119
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@everymatrix/blog-article-details",
3
- "version": "1.13.23",
3
+ "version": "1.14.0",
4
4
  "main": "./dist/index.cjs.js",
5
5
  "module": "./dist/index.js",
6
6
  "es2015": "./dist/esm/index.mjs",
@@ -1 +0,0 @@
1
- import{r as t,h as i}from"./p-68e0210a.js";const n=["ro","en","fr","ar"],r={en:{error:"Error"},ro:{error:"Eroare"},fr:{error:"Error"},ar:{error:"خطأ"}},e=class{constructor(n){t(this,n),this.language="en",this.userRoles="everyone",this.cmsEnv="stage",this.clientStyling="",this.clientStylingUrl="",this.showPublishingDate=!0,this.showImage=!0,this.showTitle=!0,this.showContent=!0,this.postMessageEvent="articleActionButton",this.intlDateTimeFormat="",this.hasErrors=!1,this.limitStylingAppends=!1,this.isLoading=!0,this.bannerMatrixReady=!1,this.device="",this.setClientStyling=()=>{let t=document.createElement("style");t.innerHTML=this.clientStyling,this.stylingContainer.prepend(t)},this.setClientStylingURL=()=>{let t=new URL(this.clientStylingUrl),i=document.createElement("style");fetch(t.href).then((t=>t.text())).then((t=>{i.innerHTML=t,setTimeout((()=>{this.stylingContainer.prepend(i)}),1)})).catch((t=>{console.log("error ",t)}))},this.renderContentConditionally=t=>-1!==(null==t?void 0:t.indexOf("<bannermatrix-banner"))?this.bannerMatrixReady?i("div",{class:"BlogContent",innerHTML:t}):null:i("div",{class:"BlogContent",innerHTML:t})}handleBannerReady(){this.bannerMatrixReady=!0}watchEndpoint(t,i){t&&t!=i&&this.cmsEndpoint&&this.getBlogArticleDetails()}connectedCallback(){this.cmsEndpoint&&this.language&&this.getBlogArticleDetails()}getBlogArticleDetails(){if(!this.postId&&isNaN(this.postId))throw this.hasErrors=!0,new Error("The postId parameter is missing!");this.isLoading=!0;let t=new URL(`${this.cmsEndpoint}/${this.language}/blog-posts/${this.postId}`);t.searchParams.append("env",this.cmsEnv),t.searchParams.append("userRoles",this.userRoles),t.searchParams.append("device",(()=>{const t=(()=>{let t=window.navigator.userAgent;return t.toLowerCase().match(/android/i)?"Android":t.toLowerCase().match(/iphone/i)?"iPhone":t.toLowerCase().match(/ipad|ipod/i)?"iPad":"PC"})();if(t)return"PC"===t?"dk":"mtWeb"})()),fetch(t.href).then((t=>{if(t.status>=300)throw this.hasErrors=!0,new Error("There was an error while fetching the data");return t.json()})).then((t=>{this.blogData=t,this.blogData.publishingDate=new Date(this.blogData.publishingDate).toLocaleDateString(),this.isLoading=!1})).catch((t=>{this.hasErrors=!0,console.log("Error",t)})).finally((()=>this.isLoading=!1))}componentDidRender(){!this.limitStylingAppends&&this.stylingContainer&&(this.clientStyling&&this.setClientStyling(),this.clientStylingUrl&&this.setClientStylingURL(),this.limitStylingAppends=!0)}componentDidLoad(){this.detectAndAlertDeviceType()}detectAndAlertDeviceType(){this.device=function(){const t=navigator.userAgent.toLowerCase(),i=screen.availWidth,n=screen.availHeight;if(t.includes("iphone"))return"mobile";if(t.includes("android")){if(n>i&&i<800)return"mobile";if(i>n&&n<800)return"tablet"}return"desktop"}()}formatDate(t){return new Intl.DateTimeFormat(this.intlDateTimeFormat).format(new Date(t))}render(){var t,e,o,s,h;return this.hasErrors?i("div",{class:"BlogArticleDetails"},i("div",{class:"Title"},(()=>{const t=this.language;return r[void 0!==t&&n.includes(t)?t:"en"].error})())):this.isLoading?void 0:i("div",{ref:t=>this.stylingContainer=t},i("div",{class:"GridContainer"},this.showPublishingDate&&i("div",{class:"BlogDate"},this.formatDate(null===(t=this.blogData)||void 0===t?void 0:t.publishingDate)),this.showImage&&i("div",{class:"BlogBanner"},(null===(e=this.blogData.image)||void 0===e?void 0:e.src)?i("img",{src:this.blogData.image.src,alt:this.blogData.image.src}):(null===(o=this.blogData.video)||void 0===o?void 0:o.sources[this.device])?i("video",{src:this.blogData.video.sources[this.device],controls:!0}):i("h1",{style:{color:"white"}},"No Image")),this.showTitle&&i("div",{class:"BlogTitle"},null===(s=this.blogData)||void 0===s?void 0:s.title),this.showContent&&this.renderContentConditionally(null===(h=this.blogData)||void 0===h?void 0:h.content)))}static get watchers(){return{cmsEndpoint:["watchEndpoint"],language:["watchEndpoint"]}}};e.style=":host {\n display: block;\n}\n\n.GridContainer {\n overflow: auto;\n margin: auto;\n width: 100%;\n padding-bottom: 30px;\n background-color: #07072A;\n display: grid;\n grid-template-rows: auto;\n grid-template-columns: 30px 60px 1fr 30px;\n gap: 10px;\n}\n.GridContainer .BlogBanner {\n grid-column: 1/5;\n grid-row: 1/3;\n}\n.GridContainer .BlogBanner img {\n width: 100%;\n height: auto;\n}\n.GridContainer .BlogDate {\n grid-column: 2/3;\n grid-row: 2/3;\n font-size: 12px;\n border-radius: 5px 5px 0 0;\n padding: 10px;\n width: fit-content;\n text-align: center;\n color: #FFF;\n background-color: #0D0D4D;\n z-index: 1;\n}\n.GridContainer .BlogTitle {\n grid-column: 2/4;\n font-size: 24px;\n color: #FFF;\n}\n.GridContainer .BlogContent {\n grid-column: 2/4;\n font-size: 14px;\n color: #FFF;\n}\n\n@container (max-width: 475px) {\n .GridContainer {\n font-size: 12px;\n }\n}";export{e as blog_article_details}
@@ -1,2 +0,0 @@
1
- import { Config } from '../../../../../../../../../stencil-public-runtime';
2
- export declare const config: Config;