mirror of
https://github.com/docmost/docmost.git
synced 2026-05-13 20:04:05 +08:00
f2a193ac8d
* other fixes and cleanups
28 lines
700 B
TypeScript
28 lines
700 B
TypeScript
export function formatMemberCount(memberCount: number): string {
|
|
if (memberCount === 1) {
|
|
return "1 member";
|
|
} else {
|
|
return `${memberCount} members`;
|
|
}
|
|
}
|
|
|
|
export function extractPageSlugId(input: string): string {
|
|
if (!input) {
|
|
return undefined;
|
|
}
|
|
const parts = input.split("-");
|
|
return parts.length > 1 ? parts[parts.length - 1] : input;
|
|
}
|
|
|
|
export const computeSpaceSlug = (name: string) => {
|
|
const alphanumericName = name.replace(/[^a-zA-Z0-9\s]/g, "");
|
|
if (alphanumericName.includes(" ")) {
|
|
return alphanumericName
|
|
.split(" ")
|
|
.map((word) => word.charAt(0).toUpperCase())
|
|
.join("");
|
|
} else {
|
|
return alphanumericName.toLowerCase();
|
|
}
|
|
};
|