From 9a620aa91b0abb74afda591f751fbfd3c12cb01e Mon Sep 17 00:00:00 2001 From: hmacr Date: Sat, 9 Aug 2025 22:03:02 +0530 Subject: [PATCH] fix: Use shared link for collection in public breadcrumb --- app/scenes/Document/components/PublicBreadcrumb.tsx | 9 ++++++--- server/models/Collection.ts | 7 ++++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/app/scenes/Document/components/PublicBreadcrumb.tsx b/app/scenes/Document/components/PublicBreadcrumb.tsx index ac041f209e..36a2ff03b1 100644 --- a/app/scenes/Document/components/PublicBreadcrumb.tsx +++ b/app/scenes/Document/components/PublicBreadcrumb.tsx @@ -1,6 +1,6 @@ import * as React from "react"; import Icon from "@shared/components/Icon"; -import { NavigationNode } from "@shared/types"; +import { NavigationNode, NavigationNodeType } from "@shared/types"; import Breadcrumb from "~/components/Breadcrumb"; import { MenuInternalLink } from "~/types"; import { sharedModelPath } from "~/utils/routeHelpers"; @@ -50,7 +50,7 @@ const PublicBreadcrumb: React.FC = ({ const items: MenuInternalLink[] = React.useMemo( () => pathToDocument(sharedTree, documentId) - .slice(1, -1) + .slice(0, -1) .map((item) => ({ ...item, icon: item.icon ? ( @@ -58,7 +58,10 @@ const PublicBreadcrumb: React.FC = ({ ) : undefined, title: item.title, type: "route", - to: sharedModelPath(shareId, item.url), + to: sharedModelPath( + shareId, + item.type === NavigationNodeType.Collection ? undefined : item.url + ), })), [sharedTree, shareId, documentId] ); diff --git a/server/models/Collection.ts b/server/models/Collection.ts index a9f033f43d..48e0810919 100644 --- a/server/models/Collection.ts +++ b/server/models/Collection.ts @@ -46,7 +46,11 @@ import { } from "sequelize-typescript"; import isUUID from "validator/lib/isUUID"; import type { CollectionSort, ProsemirrorData } from "@shared/types"; -import { CollectionPermission, NavigationNode } from "@shared/types"; +import { + CollectionPermission, + NavigationNode, + NavigationNodeType, +} from "@shared/types"; import { UrlHelper } from "@shared/utils/UrlHelper"; import { sortNavigationNodes } from "@shared/utils/collections"; import slugify from "@shared/utils/slugify"; @@ -993,6 +997,7 @@ class Collection extends ParanoidModel< id: this.id, title: this.name, url: this.path, + type: NavigationNodeType.Collection, icon: isNil(this.icon) ? undefined : this.icon, color: isNil(this.color) ? undefined : this.color, children: sortNavigationNodes(this.documentStructure ?? [], this.sort),