abmp-npm 10.0.71 → 10.0.72
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/backend/index.js +1 -0
- package/backend/public-profile-methods.js +54 -0
- package/backend/routers/utils.js +1 -0
- package/package.json +2 -1
- package/pages/index.js +1 -0
- package/pages/publicProfile.js +522 -0
- package/public/consts.js +1 -0
package/backend/index.js
CHANGED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
const { COLLECTIONS } = require('../public/consts');
|
|
2
|
+
|
|
3
|
+
const { CONFIG_KEYS } = require('./consts');
|
|
4
|
+
const { MEMBER_ACTIONS } = require('./daily-pull/consts');
|
|
5
|
+
const { wixData } = require('./elevated-modules');
|
|
6
|
+
const { findMemberByWixDataId } = require('./members-data-methods');
|
|
7
|
+
const { transformMemberToProfileData } = require('./routers/utils');
|
|
8
|
+
const { getSiteConfigs } = require('./utils');
|
|
9
|
+
|
|
10
|
+
const getPublicMemberRecord = memberDataId =>
|
|
11
|
+
wixData
|
|
12
|
+
.query(COLLECTIONS.MEMBERS_DATA_PUBLIC)
|
|
13
|
+
.eq('memberData', memberDataId)
|
|
14
|
+
.limit(1)
|
|
15
|
+
.find()
|
|
16
|
+
.then(res => res.items?.[0] || null);
|
|
17
|
+
|
|
18
|
+
async function getPublicMemberProfileData({ memberDataId }) {
|
|
19
|
+
if (!memberDataId) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const publicMember = await getPublicMemberRecord(memberDataId);
|
|
24
|
+
if (!publicMember || publicMember.showWixUrl !== true) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const member = await findMemberByWixDataId(memberDataId);
|
|
29
|
+
if (!member || member.action === MEMBER_ACTIONS.DROP || member.showWixUrl !== true) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const siteConfigs = await getSiteConfigs();
|
|
34
|
+
const siteAssociation = siteConfigs[CONFIG_KEYS.SITE_ASSOCIATION];
|
|
35
|
+
const defaultProfileImage = siteConfigs[CONFIG_KEYS.DEFAULT_PROFILE_IMAGE];
|
|
36
|
+
|
|
37
|
+
const profileData = transformMemberToProfileData(member, siteAssociation);
|
|
38
|
+
return {
|
|
39
|
+
profileData: { ...profileData, defaultProfileImage },
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
module.exports = {
|
|
44
|
+
getPublicMemberProfileData,
|
|
45
|
+
async getPublicProfileSeoConfig() {
|
|
46
|
+
const siteConfigs = await getSiteConfigs();
|
|
47
|
+
return {
|
|
48
|
+
siteAssociation: siteConfigs[CONFIG_KEYS.SITE_ASSOCIATION],
|
|
49
|
+
defaultSEODescription: siteConfigs[CONFIG_KEYS.DEFAULT_PROFILE_SEO_DESCRIPTION],
|
|
50
|
+
siteLogoUrl: siteConfigs[CONFIG_KEYS.SITE_LOGO_URL],
|
|
51
|
+
defaultProfileImage: siteConfigs[CONFIG_KEYS.DEFAULT_PROFILE_IMAGE],
|
|
52
|
+
};
|
|
53
|
+
},
|
|
54
|
+
};
|
package/backend/routers/utils.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "abmp-npm",
|
|
3
|
-
"version": "10.0.
|
|
3
|
+
"version": "10.0.72",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"check-cycles": "madge --circular .",
|
|
@@ -42,6 +42,7 @@
|
|
|
42
42
|
"@wix/secrets": "^1.0.62",
|
|
43
43
|
"@wix/site-location": "^1.31.0",
|
|
44
44
|
"@wix/site-members": "^1.32.0",
|
|
45
|
+
"@wix/site-seo": "^1.22.0",
|
|
45
46
|
"@wix/site-storage": "^1.22.0",
|
|
46
47
|
"@wix/site-window": "^1.44.0",
|
|
47
48
|
"@wix/urls": "^1.0.57",
|
package/pages/index.js
CHANGED
|
@@ -0,0 +1,522 @@
|
|
|
1
|
+
const { location: wixLocation } = require('@wix/site-location');
|
|
2
|
+
const { seo } = require('@wix/site-seo');
|
|
3
|
+
const { window: wixWindow } = require('@wix/site-window');
|
|
4
|
+
|
|
5
|
+
const { LIGHTBOX_NAMES } = require('../public/consts');
|
|
6
|
+
const {
|
|
7
|
+
generateId,
|
|
8
|
+
formatPracticeAreasForDisplay,
|
|
9
|
+
isWixHostedImage,
|
|
10
|
+
} = require('../public/Utils/sharedUtils');
|
|
11
|
+
|
|
12
|
+
const TESTIMONIALS_PER_PAGE_CONFIG = {
|
|
13
|
+
DESKTOP: 4,
|
|
14
|
+
TABLET: 2,
|
|
15
|
+
MOBILE: 1,
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const BREAKPOINTS = {
|
|
19
|
+
DESKTOP: 1301,
|
|
20
|
+
TABLET: 750,
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const resolveMemberDataId = memberData => {
|
|
24
|
+
if (!memberData) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
if (typeof memberData === 'string') {
|
|
28
|
+
return memberData;
|
|
29
|
+
}
|
|
30
|
+
return memberData?._id || memberData?._ref || null;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
async function publicProfileOnReady({
|
|
34
|
+
$w: _$w,
|
|
35
|
+
getPublicMemberProfileData,
|
|
36
|
+
getPublicProfileSeoConfig,
|
|
37
|
+
}) {
|
|
38
|
+
const dataset = _$w('#dynamicDataset');
|
|
39
|
+
let profileData = null;
|
|
40
|
+
|
|
41
|
+
let testimonialsPerPage = TESTIMONIALS_PER_PAGE_CONFIG.TABLET;
|
|
42
|
+
let currentTestimonialPage = 0;
|
|
43
|
+
|
|
44
|
+
if (typeof getPublicMemberProfileData !== 'function') {
|
|
45
|
+
console.error('[publicProfileOnReady] getPublicMemberProfileData is required');
|
|
46
|
+
wixLocation.to(`${wixLocation.baseUrl}/404`);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
await dataset.onReadyAsync();
|
|
51
|
+
const item = dataset.getCurrentItem();
|
|
52
|
+
|
|
53
|
+
if (!item || item.showWixUrl !== true) {
|
|
54
|
+
wixLocation.to(`${wixLocation.baseUrl}/404`);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const memberDataId = resolveMemberDataId(item.memberData);
|
|
59
|
+
if (!memberDataId) {
|
|
60
|
+
wixLocation.to(`${wixLocation.baseUrl}/404`);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const result = await getPublicMemberProfileData({ memberDataId });
|
|
65
|
+
profileData = result?.profileData || null;
|
|
66
|
+
|
|
67
|
+
if (!profileData) {
|
|
68
|
+
wixLocation.to(`${wixLocation.baseUrl}/404`);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (typeof getPublicProfileSeoConfig === 'function') {
|
|
73
|
+
try {
|
|
74
|
+
const seoConfig = await getPublicProfileSeoConfig();
|
|
75
|
+
applySeo(profileData, seoConfig);
|
|
76
|
+
} catch (error) {
|
|
77
|
+
console.error('[publicProfileOnReady] Failed to set SEO', error);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
initializePage();
|
|
82
|
+
|
|
83
|
+
function initializePage() {
|
|
84
|
+
bindProfileData();
|
|
85
|
+
setupAddressToggle();
|
|
86
|
+
setupResponsiveTestimonials();
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Profile data binding
|
|
90
|
+
function bindProfileData() {
|
|
91
|
+
bindAddressData();
|
|
92
|
+
bindMemberInfo();
|
|
93
|
+
bindContactInfo();
|
|
94
|
+
bindBusinessInfo();
|
|
95
|
+
bindGalleryData();
|
|
96
|
+
bindTestimonialsData();
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function bindAddressData() {
|
|
100
|
+
if (profileData.mainAddress) {
|
|
101
|
+
setTextForElements(
|
|
102
|
+
['#LocationText', '#LocationText2', '#LocationText3'],
|
|
103
|
+
profileData.mainAddress
|
|
104
|
+
);
|
|
105
|
+
} else {
|
|
106
|
+
deleteElements(['#locationContainer', '#location1Container', '#locationContainer2']);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
setupAdditionalAddresses();
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function setupAdditionalAddresses() {
|
|
113
|
+
_$w('#moreAdressesRepeater').data = profileData.moreAddressesToDisplay;
|
|
114
|
+
|
|
115
|
+
if (profileData.moreAddressesToDisplay.length > 0) {
|
|
116
|
+
_$w('#moreLocationButton').expand();
|
|
117
|
+
_$w('#addressTitle').collapse();
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
_$w('#moreAdressesRepeater').onItemReady(($item, itemData) => {
|
|
121
|
+
console.log('Item Data:', itemData);
|
|
122
|
+
$item('#adressText').text = itemData.address || '';
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function setupAddressToggle() {
|
|
127
|
+
toggleContainer('#moreLocationButton', '#addressContainer');
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function toggleContainer(buttonId, containerId) {
|
|
131
|
+
const $button = _$w(buttonId);
|
|
132
|
+
const $container = _$w(containerId);
|
|
133
|
+
|
|
134
|
+
$button.onClick(() => {
|
|
135
|
+
const isCollapsed = $container.collapsed;
|
|
136
|
+
$container[isCollapsed ? 'expand' : 'collapse']();
|
|
137
|
+
$button.label = isCollapsed ? 'Less Locations -' : 'More Locations +';
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function bindMemberInfo() {
|
|
142
|
+
bindMemberSince();
|
|
143
|
+
bindStudentBadge();
|
|
144
|
+
bindProfileImages();
|
|
145
|
+
bindFullName();
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function bindMemberSince() {
|
|
149
|
+
if (profileData.memberSince) {
|
|
150
|
+
_$w('#sinceYearText').text = profileData.memberSince;
|
|
151
|
+
} else {
|
|
152
|
+
_$w('#memberSinceBox').delete();
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function bindStudentBadge() {
|
|
157
|
+
if (profileData.shouldHaveStudentBadge) {
|
|
158
|
+
_$w('#studentContainer, #studentContainerMobile').expand();
|
|
159
|
+
} else {
|
|
160
|
+
_$w('#studentContainer, #studentContainerMobile').delete();
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function bindProfileImages() {
|
|
165
|
+
if (profileData.logoImage) {
|
|
166
|
+
_$w('#logoImage').src = profileData.logoImage;
|
|
167
|
+
} else {
|
|
168
|
+
_$w('#logoImage').delete();
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
if (profileData.profileImage && isWixHostedImage(profileData.profileImage)) {
|
|
172
|
+
_$w('#profileImage').src = profileData.profileImage;
|
|
173
|
+
} else {
|
|
174
|
+
_$w('#profileImage').src = profileData.defaultProfileImage;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
function bindFullName() {
|
|
179
|
+
if (profileData.fullName) {
|
|
180
|
+
setTextForElements(
|
|
181
|
+
['#fullNameText', '#fullNameText2', '#fullNameTextFoter'],
|
|
182
|
+
profileData.fullName
|
|
183
|
+
);
|
|
184
|
+
} else {
|
|
185
|
+
deleteElements(['#fullNameText', '#fullNameText2', '#fullNameTextFoter']);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// Contact information binding
|
|
190
|
+
function bindContactInfo() {
|
|
191
|
+
bindContactForm();
|
|
192
|
+
bindBookingUrl();
|
|
193
|
+
bindPhoneNumber();
|
|
194
|
+
bindLicenseNumber();
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function bindContactForm() {
|
|
198
|
+
if (profileData.showContactForm) {
|
|
199
|
+
_$w('#contactButton').onClick(() =>
|
|
200
|
+
wixWindow.openLightbox(LIGHTBOX_NAMES.CONTACT_US, profileData)
|
|
201
|
+
);
|
|
202
|
+
} else {
|
|
203
|
+
_$w('#contactButton').delete();
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
function bindBookingUrl() {
|
|
208
|
+
if (profileData.bookingUrl) {
|
|
209
|
+
_$w('#bookNowButton').link = profileData.bookingUrl;
|
|
210
|
+
} else {
|
|
211
|
+
_$w('#bookNowButton').delete();
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
function bindPhoneNumber() {
|
|
216
|
+
if (profileData.phone) {
|
|
217
|
+
const formattedPhoneNumber = profileData.phone.replace(/[^\d+]/g, '');
|
|
218
|
+
const getPhoneHTML = $phoneSelector =>
|
|
219
|
+
$phoneSelector.html.replace(
|
|
220
|
+
$phoneSelector.text,
|
|
221
|
+
`<a href="${`tel:${formattedPhoneNumber}`}">${profileData.phone}</a>`
|
|
222
|
+
);
|
|
223
|
+
_$w('#phoneText').html = getPhoneHTML(_$w('#phoneText'));
|
|
224
|
+
_$w('#phoneText2').html = getPhoneHTML(_$w('#phoneText2'));
|
|
225
|
+
} else {
|
|
226
|
+
deleteElements(['#phoneContainer', '#phoneContainer2']);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
function bindLicenseNumber() {
|
|
231
|
+
if (profileData.licenceNo) {
|
|
232
|
+
_$w('#licenceNoText').text = profileData.licenceNo;
|
|
233
|
+
} else {
|
|
234
|
+
_$w('#licensesContainer').delete();
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
function bindBusinessInfo() {
|
|
239
|
+
bindAboutService();
|
|
240
|
+
bindBusinessName();
|
|
241
|
+
bindAreasOfPractice();
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
function bindAboutService() {
|
|
245
|
+
if (profileData.aboutService) {
|
|
246
|
+
_$w('#aboutYouText').html = profileData.aboutService;
|
|
247
|
+
} else {
|
|
248
|
+
_$w('#aboutSection').delete();
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
function bindBusinessName() {
|
|
253
|
+
if (profileData.businessName) {
|
|
254
|
+
_$w('#businessName').text = profileData.businessName;
|
|
255
|
+
_$w('#businessName').expand();
|
|
256
|
+
} else {
|
|
257
|
+
_$w('#businessName').delete();
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
function bindAreasOfPractice() {
|
|
262
|
+
const areasText = formatPracticeAreasForDisplay(profileData.areasOfPractices);
|
|
263
|
+
|
|
264
|
+
if (areasText) {
|
|
265
|
+
_$w('#areaOfPracticesText').text = areasText;
|
|
266
|
+
} else {
|
|
267
|
+
_$w('#areaOfPracticesText').delete();
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
if (Array.isArray(profileData.areasOfPractices) && profileData.areasOfPractices.length > 0) {
|
|
271
|
+
populateRepeater(profileData.areasOfPractices, '#areaOfPracticesRepeater', '#practiceText');
|
|
272
|
+
} else {
|
|
273
|
+
_$w('#servicesSection').delete();
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
function bindGalleryData() {
|
|
278
|
+
if (profileData.bannerImages && profileData.bannerImages.length > 0) {
|
|
279
|
+
_$w('#bannerImage').src = profileData.bannerImages[0];
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
if (!profileData.gallery?.length) {
|
|
283
|
+
_$w('#gallerySection').delete();
|
|
284
|
+
} else {
|
|
285
|
+
_$w('#gallery').items = profileData.gallery;
|
|
286
|
+
_$w('#gallerySection').restore();
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
function bindTestimonialsData() {
|
|
291
|
+
if (!profileData.testimonials?.length) {
|
|
292
|
+
_$w('#testimonialsSection').delete();
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
// Responsive testimonials setup
|
|
297
|
+
async function setupResponsiveTestimonials() {
|
|
298
|
+
const { window } = await wixWindow.getBoundingRect();
|
|
299
|
+
testimonialsPerPage = getTestimonialsPerPage(window.width);
|
|
300
|
+
|
|
301
|
+
// Monitor window resize
|
|
302
|
+
setInterval(async () => {
|
|
303
|
+
const { window: win } = await wixWindow.getBoundingRect();
|
|
304
|
+
const newTestimonialsPerPage = getTestimonialsPerPage(win.width);
|
|
305
|
+
|
|
306
|
+
if (newTestimonialsPerPage !== testimonialsPerPage) {
|
|
307
|
+
testimonialsPerPage = newTestimonialsPerPage;
|
|
308
|
+
currentTestimonialPage = 0;
|
|
309
|
+
displayTestimonialsPage(profileData.testimonials);
|
|
310
|
+
}
|
|
311
|
+
}, 500);
|
|
312
|
+
|
|
313
|
+
setupTestimonialsIfAvailable();
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
function setupTestimonialsIfAvailable() {
|
|
317
|
+
if (profileData.testimonials.length > 0) {
|
|
318
|
+
setupTestimonialsPagination(profileData.testimonials);
|
|
319
|
+
_$w('#testimonialsSection').expand();
|
|
320
|
+
} else {
|
|
321
|
+
_$w('#testimonialsSection').delete();
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
function getTestimonialsPerPage(width) {
|
|
326
|
+
if (width >= BREAKPOINTS.DESKTOP) return TESTIMONIALS_PER_PAGE_CONFIG.DESKTOP;
|
|
327
|
+
if (width >= BREAKPOINTS.TABLET) return TESTIMONIALS_PER_PAGE_CONFIG.TABLET;
|
|
328
|
+
return TESTIMONIALS_PER_PAGE_CONFIG.MOBILE;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
function setTextForElements(elementIds, text) {
|
|
332
|
+
elementIds.forEach(id => {
|
|
333
|
+
_$w(id).text = text;
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
function deleteElements(elementIds) {
|
|
338
|
+
elementIds.forEach(id => {
|
|
339
|
+
_$w(id).delete();
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
function populateRepeater(data, repeaterId, textElementId) {
|
|
344
|
+
const repeaterData = data.map(item => ({
|
|
345
|
+
_id: generateId(),
|
|
346
|
+
text: item.trim(),
|
|
347
|
+
}));
|
|
348
|
+
_$w(repeaterId).data = repeaterData;
|
|
349
|
+
_$w(repeaterId).onItemReady(($item, itemData) => {
|
|
350
|
+
$item(textElementId).text = itemData.text;
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
// Testimonials pagination
|
|
355
|
+
function setupTestimonialsPagination(allTestimonials) {
|
|
356
|
+
currentTestimonialPage = 0;
|
|
357
|
+
|
|
358
|
+
_$w('#prevTestimonialBtn').onClick(() => {
|
|
359
|
+
if (currentTestimonialPage > 0) {
|
|
360
|
+
currentTestimonialPage--;
|
|
361
|
+
displayTestimonialsPage(allTestimonials);
|
|
362
|
+
}
|
|
363
|
+
});
|
|
364
|
+
|
|
365
|
+
_$w('#nextTestimonialBtn').onClick(() => {
|
|
366
|
+
const maxPage = Math.floor((allTestimonials.length - 1) / testimonialsPerPage);
|
|
367
|
+
if (currentTestimonialPage < maxPage) {
|
|
368
|
+
currentTestimonialPage++;
|
|
369
|
+
displayTestimonialsPage(allTestimonials);
|
|
370
|
+
}
|
|
371
|
+
});
|
|
372
|
+
|
|
373
|
+
displayTestimonialsPage(allTestimonials);
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
function displayTestimonialsPage(allTestimonials) {
|
|
377
|
+
const start = currentTestimonialPage * testimonialsPerPage;
|
|
378
|
+
const end = start + testimonialsPerPage;
|
|
379
|
+
const currentBatch = allTestimonials.slice(start, end);
|
|
380
|
+
|
|
381
|
+
populateRepeater(currentBatch, '#testimonialsrepeater', '#testimonialText');
|
|
382
|
+
updateTestimonialNavigation(end, allTestimonials.length);
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
function updateTestimonialNavigation(end, totalLength) {
|
|
386
|
+
_$w('#prevTestimonialBtn').hide();
|
|
387
|
+
_$w('#nextTestimonialBtn').hide();
|
|
388
|
+
|
|
389
|
+
if (currentTestimonialPage > 0) {
|
|
390
|
+
_$w('#prevTestimonialBtn').show();
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
if (end < totalLength) {
|
|
394
|
+
_$w('#nextTestimonialBtn').show();
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
function applySeo(data, config) {
|
|
399
|
+
if (!data || !config) {
|
|
400
|
+
return;
|
|
401
|
+
}
|
|
402
|
+
const { siteAssociation, defaultSEODescription, siteLogoUrl, defaultProfileImage } = config;
|
|
403
|
+
|
|
404
|
+
const profileImage =
|
|
405
|
+
data.profileImage?.trim() && isWixHostedImage(data.profileImage)
|
|
406
|
+
? data.profileImage
|
|
407
|
+
: defaultProfileImage;
|
|
408
|
+
const ogImage = profileImage || data.logoImage || siteLogoUrl;
|
|
409
|
+
const seoTitle = generateSEOTitle({
|
|
410
|
+
fullName: data.fullName,
|
|
411
|
+
areasOfPractices: data.areasOfPractices,
|
|
412
|
+
siteAssociation,
|
|
413
|
+
});
|
|
414
|
+
let description = stripHtmlTags(data.aboutService) || defaultSEODescription || '';
|
|
415
|
+
if (description.length > 160) {
|
|
416
|
+
description = description.substring(0, 157) + '...';
|
|
417
|
+
}
|
|
418
|
+
const profileUrl = data.url
|
|
419
|
+
? `${wixLocation.baseUrl}/profile/${data.url}`
|
|
420
|
+
: wixLocation.baseUrl;
|
|
421
|
+
const shouldNoIndex = data.isPrivateMember || data.shouldHaveStudentBadge;
|
|
422
|
+
|
|
423
|
+
seo.setTitle(seoTitle);
|
|
424
|
+
seo.setMetaTags(
|
|
425
|
+
[
|
|
426
|
+
{
|
|
427
|
+
name: 'description',
|
|
428
|
+
content: description,
|
|
429
|
+
},
|
|
430
|
+
{
|
|
431
|
+
name: 'keywords',
|
|
432
|
+
content:
|
|
433
|
+
`${data.fullName}, ${data.areasOfPractices ? data.areasOfPractices.slice(0, 3).join(', ') : ''}, ${siteAssociation}, ${data.city || ''}, ${data.state || ''}`
|
|
434
|
+
.replace(/,\s*,/g, ',')
|
|
435
|
+
.replace(/^,|,$/g, ''),
|
|
436
|
+
},
|
|
437
|
+
{
|
|
438
|
+
name: 'author',
|
|
439
|
+
content: data.fullName,
|
|
440
|
+
},
|
|
441
|
+
{
|
|
442
|
+
name: 'robots',
|
|
443
|
+
content: shouldNoIndex ? 'noindex, nofollow' : 'index, follow',
|
|
444
|
+
},
|
|
445
|
+
{
|
|
446
|
+
property: 'og:type',
|
|
447
|
+
content: 'profile',
|
|
448
|
+
},
|
|
449
|
+
{
|
|
450
|
+
property: 'og:title',
|
|
451
|
+
content: seoTitle,
|
|
452
|
+
},
|
|
453
|
+
{
|
|
454
|
+
property: 'og:description',
|
|
455
|
+
content: description,
|
|
456
|
+
},
|
|
457
|
+
{
|
|
458
|
+
property: 'og:image',
|
|
459
|
+
content: ogImage,
|
|
460
|
+
},
|
|
461
|
+
{
|
|
462
|
+
property: 'og:url',
|
|
463
|
+
content: profileUrl,
|
|
464
|
+
},
|
|
465
|
+
{
|
|
466
|
+
property: 'og:site_name',
|
|
467
|
+
content: `${siteAssociation} Members`,
|
|
468
|
+
},
|
|
469
|
+
{
|
|
470
|
+
name: 'twitter:card',
|
|
471
|
+
content: 'summary_large_image',
|
|
472
|
+
},
|
|
473
|
+
{
|
|
474
|
+
name: 'twitter:title',
|
|
475
|
+
content: seoTitle,
|
|
476
|
+
},
|
|
477
|
+
{
|
|
478
|
+
name: 'twitter:description',
|
|
479
|
+
content: description,
|
|
480
|
+
},
|
|
481
|
+
{
|
|
482
|
+
name: 'twitter:image',
|
|
483
|
+
content: ogImage,
|
|
484
|
+
},
|
|
485
|
+
{
|
|
486
|
+
name: 'geo.region',
|
|
487
|
+
content: data.state || '',
|
|
488
|
+
},
|
|
489
|
+
{
|
|
490
|
+
name: 'geo.placename',
|
|
491
|
+
content: data.city || '',
|
|
492
|
+
},
|
|
493
|
+
].filter(tag => tag.content && tag.content.trim() !== '')
|
|
494
|
+
);
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
function generateSEOTitle({ fullName, areasOfPractices, siteAssociation }) {
|
|
498
|
+
return `${fullName}${
|
|
499
|
+
areasOfPractices && areasOfPractices.length > 0
|
|
500
|
+
? ` | ${areasOfPractices.slice(0, 3).join(', ')}`
|
|
501
|
+
: ''
|
|
502
|
+
} | ${siteAssociation} Member`;
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
function stripHtmlTags(html) {
|
|
506
|
+
if (!html) return '';
|
|
507
|
+
return html
|
|
508
|
+
.replace(/<[^>]*>/g, '')
|
|
509
|
+
.replace(/ /g, ' ')
|
|
510
|
+
.replace(/&/g, '&')
|
|
511
|
+
.replace(/</g, '<')
|
|
512
|
+
.replace(/>/g, '>')
|
|
513
|
+
.replace(/"/g, '"')
|
|
514
|
+
.replace(/'/g, "'")
|
|
515
|
+
.replace(/\s+/g, ' ')
|
|
516
|
+
.trim();
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
module.exports = {
|
|
521
|
+
publicProfileOnReady,
|
|
522
|
+
};
|
package/public/consts.js
CHANGED