mirror of
https://github.com/CompassConnections/Compass.git
synced 2026-03-31 04:52:47 -04:00
Handle null site
This commit is contained in:
@@ -20,18 +20,20 @@ export function UserHandles(props: {links: Socials; className?: string}) {
|
||||
const display = sortBy(
|
||||
Object.entries(links),
|
||||
([platform]) => -[...SITE_ORDER].reverse().indexOf(platform as Site),
|
||||
).map(([platform, label]) => {
|
||||
let renderedLabel: string = LABELS_TO_RENDER.includes(platform)
|
||||
? PLATFORM_LABELS[platform as Site]
|
||||
: label
|
||||
renderedLabel = renderedLabel?.replace(/\/+$/, '') // remove trailing slashes
|
||||
renderedLabel = renderedLabel?.replace(/^(https?:\/\/)?(www\.)?/, '') // remove protocol and www
|
||||
return {
|
||||
platform,
|
||||
label: renderedLabel,
|
||||
url: getSocialUrl(platform as any, label),
|
||||
}
|
||||
})
|
||||
)
|
||||
.filter(([platform, label]) => !!label && !!platform)
|
||||
.map(([platform, label]) => {
|
||||
let renderedLabel: string = LABELS_TO_RENDER.includes(platform)
|
||||
? PLATFORM_LABELS[platform as Site]
|
||||
: label
|
||||
renderedLabel = renderedLabel?.replace(/\/+$/, '') // remove trailing slashes
|
||||
renderedLabel = renderedLabel?.replace(/^(https?:\/\/)?(www\.)?/, '') // remove protocol and www
|
||||
return {
|
||||
platform,
|
||||
label: renderedLabel,
|
||||
url: getSocialUrl(platform as any, label),
|
||||
}
|
||||
})
|
||||
|
||||
if (display.length === 0) {
|
||||
return null
|
||||
|
||||
Reference in New Issue
Block a user