@salesforcedevs/dw-components 1.14.7-alpha → 1.14.7-alpha3
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,5 +1,8 @@
|
|
|
1
1
|
import { LightningElement, api, track } from "lwc";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
fetchSingleWordpressPost,
|
|
4
|
+
fetchWordpressPosts
|
|
5
|
+
} from "dxUtils/wordpress";
|
|
3
6
|
import { normalizePost } from "dxUtils/normalizers";
|
|
4
7
|
|
|
5
8
|
type BlogPost = {
|
|
@@ -25,7 +28,7 @@ export default class CardBlogPostProvider extends LightningElement {
|
|
|
25
28
|
this._filteredPosts = this.filterOutFeaturedPost(posts);
|
|
26
29
|
this._posts = posts;
|
|
27
30
|
}
|
|
28
|
-
|
|
31
|
+
|
|
29
32
|
get filteredPosts() {
|
|
30
33
|
return this._filteredPosts;
|
|
31
34
|
}
|
|
@@ -34,7 +37,7 @@ export default class CardBlogPostProvider extends LightningElement {
|
|
|
34
37
|
this._featuredPost = featuredPost;
|
|
35
38
|
this._filteredPosts = this.filterOutFeaturedPost(this._posts);
|
|
36
39
|
}
|
|
37
|
-
|
|
40
|
+
|
|
38
41
|
get featuredPost() {
|
|
39
42
|
return this._featuredPost;
|
|
40
43
|
}
|
|
@@ -52,30 +55,27 @@ export default class CardBlogPostProvider extends LightningElement {
|
|
|
52
55
|
}
|
|
53
56
|
|
|
54
57
|
private filterOutFeaturedPost(posts: BlogPost[]) {
|
|
55
|
-
|
|
56
|
-
const numberOfPostsMinusOne = parseInt(this.count, 10) - 1;
|
|
57
|
-
return posts.filter((post) => post.id !== this._featuredPost.id).slice(0, numberOfPostsMinusOne);
|
|
58
|
+
return posts.filter((post) => post.id !== this._featuredPost.id);
|
|
58
59
|
}
|
|
59
60
|
|
|
60
61
|
private fetchPosts = async () => {
|
|
61
|
-
// in case we get the featured post, we may need an extra
|
|
62
|
-
const numberOfPostsPlusOne = parseInt(this.count, 10) + 1;
|
|
63
62
|
this.posts = await fetchWordpressPosts(
|
|
64
63
|
"/blogs/api",
|
|
65
64
|
normalizePost,
|
|
66
|
-
|
|
65
|
+
this.count
|
|
67
66
|
);
|
|
68
67
|
};
|
|
69
68
|
|
|
70
69
|
private fetchFeaturedPost = async () => {
|
|
71
|
-
|
|
70
|
+
const FEATURED_BLOG_POST_ID = process.env.FEATURED_BLOG_POST_ID;
|
|
71
|
+
if (FEATURED_BLOG_POST_ID) {
|
|
72
72
|
this.featuredPost = await fetchSingleWordpressPost(
|
|
73
73
|
"/blogs/wp-json/wp/v2/posts",
|
|
74
|
-
|
|
74
|
+
FEATURED_BLOG_POST_ID,
|
|
75
75
|
normalizePost
|
|
76
76
|
);
|
|
77
77
|
}
|
|
78
|
-
}
|
|
78
|
+
};
|
|
79
79
|
|
|
80
80
|
connectedCallback() {
|
|
81
81
|
this.fetchFeaturedPost();
|