Coves frontend - a photon fork
at main 24 lines 657 B view raw
1import type { CommunityRef, CommunityView } from '$lib/api/coves/types' 2 3/** 4 * Returns the identifier string for a community (for URLs, route params, etc.). 5 * Prefers `handle` over `name`. 6 */ 7export function communityIdentifier( 8 community: CommunityView | CommunityRef, 9): string { 10 return community.handle ?? community.name 11} 12 13/** 14 * Returns the human-readable display name for a community. 15 * Prefers `displayName` over `name`. 16 */ 17export function communityDisplayName( 18 community: CommunityView | CommunityRef, 19): string { 20 if ('displayName' in community && community.displayName) { 21 return community.displayName 22 } 23 return community.name 24}