mirror of
https://github.com/docmost/docmost.git
synced 2026-05-07 22:53:08 +08:00
6c422011ac
* Share - WIP * - public attachment links - WIP * WIP * WIP * Share - WIP * WIP * WIP * include userRole in space object * WIP * Server render shared page meta tags * disable user select * Close Navbar on outside click on mobile * update shared page spaceId * WIP * fix * close sidebar on click * close sidebar * defaults * update copy * Store share key in lowercase * refactor page breadcrumbs * Change copy * add link ref * open link button * add meta og:title * add twitter tags * WIP * make shares/info endpoint public * fix * * add /p/ segment to share urls * minore fixes * change mobile breadcrumb icon
37 lines
929 B
TypeScript
37 lines
929 B
TypeScript
import slugify from "@sindresorhus/slugify";
|
|
|
|
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)}`;
|
|
};
|
|
|
|
export const buildSharedPageUrl = (opts: {
|
|
shareId: string;
|
|
pageSlugId: string;
|
|
pageTitle?: string;
|
|
}): string => {
|
|
const { shareId, pageSlugId, pageTitle } = opts;
|
|
if (!shareId) {
|
|
return `/share/p/${buildPageSlug(pageSlugId, pageTitle)}`;
|
|
}
|
|
|
|
return `/share/${shareId}/p/${buildPageSlug(pageSlugId, pageTitle)}`;
|
|
};
|