abmp-npm 10.0.67 → 10.0.69
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.
|
@@ -42,4 +42,13 @@ async function getPublicMemberProfileData({ memberDataId }) {
|
|
|
42
42
|
|
|
43
43
|
module.exports = {
|
|
44
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
|
+
},
|
|
45
54
|
};
|
package/package.json
CHANGED
package/pages/publicProfile.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const { location: wixLocation } = require('@wix/site-location');
|
|
2
|
+
const { seo } = require('@wix/site-seo');
|
|
2
3
|
const { window: wixWindow } = require('@wix/site-window');
|
|
3
4
|
|
|
4
5
|
const { LIGHTBOX_NAMES } = require('../public/consts');
|
|
@@ -29,7 +30,11 @@ const resolveMemberDataId = memberData => {
|
|
|
29
30
|
return memberData?._id || memberData?._ref || null;
|
|
30
31
|
};
|
|
31
32
|
|
|
32
|
-
async function publicProfileOnReady({
|
|
33
|
+
async function publicProfileOnReady({
|
|
34
|
+
$w: _$w,
|
|
35
|
+
getPublicMemberProfileData,
|
|
36
|
+
getPublicProfileSeoConfig,
|
|
37
|
+
}) {
|
|
33
38
|
const dataset = _$w('#dynamicDataset');
|
|
34
39
|
let profileData = null;
|
|
35
40
|
|
|
@@ -44,6 +49,7 @@ async function publicProfileOnReady({ $w: _$w, getPublicMemberProfileData }) {
|
|
|
44
49
|
|
|
45
50
|
await dataset.onReadyAsync();
|
|
46
51
|
const item = dataset.getCurrentItem();
|
|
52
|
+
|
|
47
53
|
if (!item || item.showWixUrl !== true) {
|
|
48
54
|
wixLocation.to(`${wixLocation.baseUrl}/404`);
|
|
49
55
|
return;
|
|
@@ -63,6 +69,15 @@ async function publicProfileOnReady({ $w: _$w, getPublicMemberProfileData }) {
|
|
|
63
69
|
return;
|
|
64
70
|
}
|
|
65
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
|
+
|
|
66
81
|
initializePage();
|
|
67
82
|
|
|
68
83
|
function initializePage() {
|
|
@@ -379,6 +394,128 @@ async function publicProfileOnReady({ $w: _$w, getPublicMemberProfileData }) {
|
|
|
379
394
|
_$w('#nextTestimonialBtn').show();
|
|
380
395
|
}
|
|
381
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.setDescription(description);
|
|
425
|
+
seo.setMetaTags(
|
|
426
|
+
[
|
|
427
|
+
{
|
|
428
|
+
name: 'description',
|
|
429
|
+
content: description,
|
|
430
|
+
},
|
|
431
|
+
{
|
|
432
|
+
name: 'keywords',
|
|
433
|
+
content:
|
|
434
|
+
`${data.fullName}, ${data.areasOfPractices ? data.areasOfPractices.slice(0, 3).join(', ') : ''}, ${siteAssociation}, ${data.city || ''}, ${data.state || ''}`
|
|
435
|
+
.replace(/,\s*,/g, ',')
|
|
436
|
+
.replace(/^,|,$/g, ''),
|
|
437
|
+
},
|
|
438
|
+
{
|
|
439
|
+
name: 'author',
|
|
440
|
+
content: data.fullName,
|
|
441
|
+
},
|
|
442
|
+
{
|
|
443
|
+
name: 'robots',
|
|
444
|
+
content: shouldNoIndex ? 'noindex, nofollow' : 'index, follow',
|
|
445
|
+
},
|
|
446
|
+
{
|
|
447
|
+
property: 'og:type',
|
|
448
|
+
content: 'profile',
|
|
449
|
+
},
|
|
450
|
+
{
|
|
451
|
+
property: 'og:title',
|
|
452
|
+
content: seoTitle,
|
|
453
|
+
},
|
|
454
|
+
{
|
|
455
|
+
property: 'og:description',
|
|
456
|
+
content: description,
|
|
457
|
+
},
|
|
458
|
+
{
|
|
459
|
+
property: 'og:image',
|
|
460
|
+
content: ogImage,
|
|
461
|
+
},
|
|
462
|
+
{
|
|
463
|
+
property: 'og:url',
|
|
464
|
+
content: profileUrl,
|
|
465
|
+
},
|
|
466
|
+
{
|
|
467
|
+
property: 'og:site_name',
|
|
468
|
+
content: `${siteAssociation} Members`,
|
|
469
|
+
},
|
|
470
|
+
{
|
|
471
|
+
name: 'twitter:card',
|
|
472
|
+
content: 'summary_large_image',
|
|
473
|
+
},
|
|
474
|
+
{
|
|
475
|
+
name: 'twitter:title',
|
|
476
|
+
content: seoTitle,
|
|
477
|
+
},
|
|
478
|
+
{
|
|
479
|
+
name: 'twitter:description',
|
|
480
|
+
content: description,
|
|
481
|
+
},
|
|
482
|
+
{
|
|
483
|
+
name: 'twitter:image',
|
|
484
|
+
content: ogImage,
|
|
485
|
+
},
|
|
486
|
+
{
|
|
487
|
+
name: 'geo.region',
|
|
488
|
+
content: data.state || '',
|
|
489
|
+
},
|
|
490
|
+
{
|
|
491
|
+
name: 'geo.placename',
|
|
492
|
+
content: data.city || '',
|
|
493
|
+
},
|
|
494
|
+
].filter(tag => tag.content && tag.content.trim() !== '')
|
|
495
|
+
);
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
function generateSEOTitle({ fullName, areasOfPractices, siteAssociation }) {
|
|
499
|
+
return `${fullName}${
|
|
500
|
+
areasOfPractices && areasOfPractices.length > 0
|
|
501
|
+
? ` | ${areasOfPractices.slice(0, 3).join(', ')}`
|
|
502
|
+
: ''
|
|
503
|
+
} | ${siteAssociation} Member`;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
function stripHtmlTags(html) {
|
|
507
|
+
if (!html) return '';
|
|
508
|
+
return html
|
|
509
|
+
.replace(/<[^>]*>/g, '')
|
|
510
|
+
.replace(/ /g, ' ')
|
|
511
|
+
.replace(/&/g, '&')
|
|
512
|
+
.replace(/</g, '<')
|
|
513
|
+
.replace(/>/g, '>')
|
|
514
|
+
.replace(/"/g, '"')
|
|
515
|
+
.replace(/'/g, "'")
|
|
516
|
+
.replace(/\s+/g, ' ')
|
|
517
|
+
.trim();
|
|
518
|
+
}
|
|
382
519
|
}
|
|
383
520
|
|
|
384
521
|
module.exports = {
|