@salesforcedevs/dx-components 1.3.222-alpha2 → 1.3.222-alpha4
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.
package/package.json
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<dx-section class="section-reduced-padding">
|
|
3
|
-
<dx-spinner>
|
|
3
|
+
<dx-spinner if:true={recommendationsLoaded}>
|
|
4
4
|
<div class="spinner-container">
|
|
5
5
|
<dx-spinner size="large" variant="brand"></dx-spinner>
|
|
6
6
|
</div>
|
|
7
7
|
</dx-spinner>
|
|
8
8
|
<template for:each={recommendations} for:item="recommendation">
|
|
9
9
|
<dx-card-blog-post
|
|
10
|
-
authors={recommendation.
|
|
10
|
+
authors={recommendation.authors}
|
|
11
11
|
body={recommendation.yoast_head_json.description}
|
|
12
12
|
datetime={recommendation.yoast_head_json.article_published_time}
|
|
13
13
|
href={recommendation.yoast_head_json.canonical}
|
|
14
14
|
img-alt={recommendation.yoast_head_json.title}
|
|
15
15
|
img-src={recommendation.content.featured_image}
|
|
16
|
+
key={recommendation.id}
|
|
16
17
|
title={recommendation.yoast_head_json.title}
|
|
17
18
|
></dx-card-blog-post>
|
|
18
19
|
</template>
|
|
@@ -5,6 +5,7 @@ export default class CoveoRecommendations extends LightningElement {
|
|
|
5
5
|
@api coveoAuthToken!: string;
|
|
6
6
|
|
|
7
7
|
recommendations = [];
|
|
8
|
+
recommendationsLoaded = false;
|
|
8
9
|
|
|
9
10
|
renderedCallback() {
|
|
10
11
|
// const actionsHistory = localStorage.getItem(
|
|
@@ -13,6 +14,7 @@ export default class CoveoRecommendations extends LightningElement {
|
|
|
13
14
|
const url = "https://platform.cloud.coveo.com/rest/search/v2";
|
|
14
15
|
fetch(url, {
|
|
15
16
|
headers: { Authorization: `Bearer ${this.coveoAuthToken}` },
|
|
17
|
+
method: "POST",
|
|
16
18
|
body: JSON.stringify({
|
|
17
19
|
pipeline: "Recommendations_Developer_Blogs",
|
|
18
20
|
searchHub: "developerWebsiteBlogs",
|
|
@@ -32,12 +34,13 @@ export default class CoveoRecommendations extends LightningElement {
|
|
|
32
34
|
this.recommendations = recommendations;
|
|
33
35
|
const blogPosts = recommendations.slice(0, 3).map(async (rec) => {
|
|
34
36
|
const slug = rec.uri.split("/").pop();
|
|
35
|
-
const blogDataUrl =
|
|
37
|
+
const blogDataUrl = `https://developer.salesforce.com/blogs/wp-json/wp/v2/posts?slug=${slug}&state=publish&_embed=wp:featuredmedia`;
|
|
36
38
|
const blogData = (await (await fetch(blogDataUrl)).json())[0];
|
|
37
39
|
console.log(blogData);
|
|
38
40
|
return blogData;
|
|
39
41
|
});
|
|
40
42
|
this.recommendations = blogPosts;
|
|
43
|
+
this.recommendationsLoaded = true;
|
|
41
44
|
});
|
|
42
45
|
}
|
|
43
46
|
|