@salesforcedevs/dx-components 0.53.10 → 0.53.11-alpha
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/lwc.config.json +15 -17
- package/package.json +3 -6
- package/src/modules/base-elements/headerBase/headerBase.ts +1 -1
- package/src/modules/dx/cardCallout/cardCallout.ts +4 -4
- package/src/modules/dx/cardNews/cardNews.ts +1 -1
- package/src/modules/dx/codeBlock/codeBlock.ts +1 -1
- package/src/modules/dx/dropdownOption/dropdownOption.ts +1 -1
- package/src/modules/dx/footer/footer.ts +1 -1
- package/src/modules/dx/footerOption/footerOption.ts +1 -1
- package/src/modules/dx/groupText/groupText.ts +1 -1
- package/src/modules/dx/headerMobileNavMenuOption/headerMobileNavMenuOption.ts +1 -1
- package/src/modules/dx/pagination/pagination.ts +1 -1
- package/src/modules/dx/sidebar/sidebar.ts +1 -1
- package/src/modules/dx/sidebarOld/sidebarOld.ts +1 -1
- package/src/modules/dx/tab/tab.ts +1 -1
- package/src/modules/dx/treeItem/treeItem.ts +1 -1
- package/src/modules/utils/analytics/analytics.ts +24 -0
- package/LICENSE +0 -12
- package/src/modules/dx/cardBlogPostProvider/cardBlogPostProvider.css +0 -3
- package/src/modules/dx/cardBlogPostProvider/cardBlogPostProvider.html +0 -16
- package/src/modules/dx/cardBlogPostProvider/cardBlogPostProvider.ts +0 -29
- package/src/modules/dx/cardPodcastEpisodeProvider/cardPodcastEpisodeProvider.css +0 -3
- package/src/modules/dx/cardPodcastEpisodeProvider/cardPodcastEpisodeProvider.html +0 -12
- package/src/modules/dx/cardPodcastEpisodeProvider/cardPodcastEpisodeProvider.ts +0 -29
- package/src/modules/dx/contentArchive/contentArchive.css +0 -242
- package/src/modules/dx/contentArchive/contentArchive.html +0 -337
- package/src/modules/dx/contentArchive/contentArchive.ts +0 -461
- package/src/modules/dx/contentArchive/contentArchive.types.ts +0 -6
- package/src/modules/dx/instrumentation/instrumentation.html +0 -1
- package/src/modules/dx/instrumentation/instrumentation.ts +0 -116
- package/src/modules/dx/newsletterForm/newsletterForm.css +0 -73
- package/src/modules/dx/newsletterForm/newsletterForm.html +0 -73
- package/src/modules/dx/newsletterForm/newsletterForm.ts +0 -238
- package/src/modules/dx/podcastSubscription/podcastSubscription.css +0 -91
- package/src/modules/dx/podcastSubscription/podcastSubscription.html +0 -24
- package/src/modules/dx/podcastSubscription/podcastSubscription.ts +0 -52
- package/src/modules/dx/searchResults/coveo.css +0 -18989
- package/src/modules/dx/searchResults/searchResults.css +0 -387
- package/src/modules/dx/searchResults/searchResults.html +0 -104
- package/src/modules/dx/searchResults/searchResults.ts +0 -186
- package/src/modules/dx/slackCta/slackCta.css +0 -47
- package/src/modules/dx/slackCta/slackCta.html +0 -17
- package/src/modules/dx/slackCta/slackCta.ts +0 -12
- package/src/modules/utils/contentArchive/altData.js +0 -3
- package/src/modules/utils/contentArchive/contentArchive.ts +0 -163
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
import qs from "query-string";
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
ArchivePost,
|
|
5
|
-
ArchivePostNormalized,
|
|
6
|
-
FilterMenuData
|
|
7
|
-
} from "typings/custom";
|
|
8
|
-
import altData from "./altData.js";
|
|
9
|
-
|
|
10
|
-
let controller: AbortController | null = null;
|
|
11
|
-
|
|
12
|
-
const ARCHIVE_BASE_URL = "https://developer.salesforce.com/blogs/wp-json/wp/v2";
|
|
13
|
-
const ARCHIVE_CONTENT_URL = `${ARCHIVE_BASE_URL}/latest-post-per-site`;
|
|
14
|
-
const ARCHIVE_FILTER_LIST_URL = `${ARCHIVE_BASE_URL}/archives-filters?order=DESC`;
|
|
15
|
-
|
|
16
|
-
async function postsFetchHandler(url: string) {
|
|
17
|
-
if (controller) {
|
|
18
|
-
controller.abort();
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
controller = new AbortController();
|
|
22
|
-
const { signal } = controller;
|
|
23
|
-
|
|
24
|
-
const response = await fetch(url, { signal });
|
|
25
|
-
|
|
26
|
-
if (response.ok) {
|
|
27
|
-
return {
|
|
28
|
-
posts: await response.json(),
|
|
29
|
-
totalPages: Number(response.headers.get("x-wp-totalpages")),
|
|
30
|
-
totalResults: Number(response.headers.get("x-wp-total"))
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
console.error("Error fetching posts");
|
|
35
|
-
|
|
36
|
-
return {
|
|
37
|
-
posts: [],
|
|
38
|
-
totalResults: 0,
|
|
39
|
-
totalPages: 0
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function getAudioDuration(duration: string) {
|
|
44
|
-
const durationSplit = duration.split(":");
|
|
45
|
-
const hours = Number(durationSplit[0]);
|
|
46
|
-
const minutes = Number(durationSplit[1]);
|
|
47
|
-
const seconds = Number(durationSplit[2]);
|
|
48
|
-
|
|
49
|
-
const roundSecondsIntoMinutes = Math.round(seconds / 60);
|
|
50
|
-
|
|
51
|
-
return hours
|
|
52
|
-
? `${minutes + roundSecondsIntoMinutes * (hours * 60)} MIN`
|
|
53
|
-
: `${minutes + roundSecondsIntoMinutes} MIN`;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function normalizePosts(posts: Array<ArchivePost>, contentType: string) {
|
|
57
|
-
return posts.map((post) => ({
|
|
58
|
-
id: post.id,
|
|
59
|
-
title: post.title.rendered,
|
|
60
|
-
date: post.date,
|
|
61
|
-
contentType: post.sitename,
|
|
62
|
-
href: post.link,
|
|
63
|
-
...(contentType === "expanded" && {
|
|
64
|
-
excerpt: post.excerpt,
|
|
65
|
-
duration: getAudioDuration(post.podcast_audio.duration),
|
|
66
|
-
...(post._embedded &&
|
|
67
|
-
post._embedded.author[0].id && {
|
|
68
|
-
author: post._embedded.author[0],
|
|
69
|
-
authorImgSrc: post._embedded.author[0].avatar_urls["24"],
|
|
70
|
-
topics: post._embedded["wp:term"][0].map(
|
|
71
|
-
(term: any) => term.name
|
|
72
|
-
)
|
|
73
|
-
})
|
|
74
|
-
})
|
|
75
|
-
}));
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export async function getArchivePosts(
|
|
79
|
-
count: number = 10,
|
|
80
|
-
page: number = 1,
|
|
81
|
-
contentType: string = "minimal",
|
|
82
|
-
filterMenuData: FilterMenuData
|
|
83
|
-
): Promise<ArchivePostNormalized> {
|
|
84
|
-
const filterQuery = {
|
|
85
|
-
site: filterMenuData.site.map((siteType) => siteType.id),
|
|
86
|
-
dates: filterMenuData.dates.map((date) =>
|
|
87
|
-
date.shortName ? date.shortName : date.id
|
|
88
|
-
),
|
|
89
|
-
author: filterMenuData.authors.map((author) => author.id),
|
|
90
|
-
category: filterMenuData.categories.map((category) => category.id)
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
const COMMON_FIELDS = [
|
|
94
|
-
"id",
|
|
95
|
-
"title",
|
|
96
|
-
"date",
|
|
97
|
-
"sitename",
|
|
98
|
-
"link",
|
|
99
|
-
"podcast_audio"
|
|
100
|
-
];
|
|
101
|
-
const EXPANDED_FIELDS = [
|
|
102
|
-
"excerpt",
|
|
103
|
-
"_embedded",
|
|
104
|
-
"_links.author",
|
|
105
|
-
"_links.wp:term.0"
|
|
106
|
-
];
|
|
107
|
-
|
|
108
|
-
const query: any = {
|
|
109
|
-
...filterQuery,
|
|
110
|
-
_fields: ["id", "title", "date", "sitename", "link"],
|
|
111
|
-
per_page: count,
|
|
112
|
-
page
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
if (contentType === "minimal") {
|
|
116
|
-
query._fields.filter((field: string) =>
|
|
117
|
-
EXPANDED_FIELDS.includes(field)
|
|
118
|
-
);
|
|
119
|
-
delete query._embed;
|
|
120
|
-
} else {
|
|
121
|
-
query._fields = [...COMMON_FIELDS, ...EXPANDED_FIELDS];
|
|
122
|
-
query._embed = ["author", "wp:term"];
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
const postsUrl = `${qs.stringifyUrl(
|
|
126
|
-
{
|
|
127
|
-
url: ARCHIVE_CONTENT_URL,
|
|
128
|
-
query
|
|
129
|
-
},
|
|
130
|
-
{ arrayFormat: "comma" }
|
|
131
|
-
)}`;
|
|
132
|
-
|
|
133
|
-
// need to format dates with brackets instead of commas
|
|
134
|
-
const urlWithoutDates = qs.pick(
|
|
135
|
-
postsUrl,
|
|
136
|
-
(name: string) => name !== "dates"
|
|
137
|
-
);
|
|
138
|
-
const dateString = qs.stringify(
|
|
139
|
-
{ dates: query.dates },
|
|
140
|
-
{ arrayFormat: "bracket" }
|
|
141
|
-
);
|
|
142
|
-
|
|
143
|
-
const { posts, totalPages, totalResults } = await postsFetchHandler(
|
|
144
|
-
`${urlWithoutDates}${dateString && "&"}${dateString}`
|
|
145
|
-
);
|
|
146
|
-
|
|
147
|
-
return {
|
|
148
|
-
posts: normalizePosts(posts, contentType),
|
|
149
|
-
totalPages,
|
|
150
|
-
totalResults
|
|
151
|
-
};
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
export async function getArchiveFilterList() {
|
|
155
|
-
const response = await fetch(ARCHIVE_FILTER_LIST_URL);
|
|
156
|
-
|
|
157
|
-
if (response.ok) {
|
|
158
|
-
return response.json();
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
console.error("Error fetching filter list, using fallback instead");
|
|
162
|
-
return altData;
|
|
163
|
-
}
|