mirror of
https://github.com/docmost/docmost.git
synced 2025-11-17 10:31:18 +10:00
24 lines
601 B
TypeScript
24 lines
601 B
TypeScript
import slugify from "@sindresorhus/slugify";
|
|
|
|
export const buildPageSlug = (pageSlugId: string, pageTitle?: string): string => {
|
|
const titleSlug = slugify(pageTitle?.substring(0, 70) || "untitled", {
|
|
customReplacements: [
|
|
["♥", ""],
|
|
["🦄", ""],
|
|
],
|
|
});
|
|
|
|
return `${titleSlug}-${pageSlugId}`;
|
|
};
|
|
|
|
export const buildPageUrl = (
|
|
spaceName: string,
|
|
pageSlugId: string,
|
|
pageTitle?: string,
|
|
): string => {
|
|
if (spaceName === undefined) {
|
|
return `/p/${buildPageSlug(pageSlugId, pageTitle)}`;
|
|
}
|
|
return `/s/${spaceName}/p/${buildPageSlug(pageSlugId, pageTitle)}`;
|
|
};
|