From 7b69727a3041942d5dd4e8cd279281ad41884466 Mon Sep 17 00:00:00 2001
From: Philip Okugbe <16838612+Philipinho@users.noreply.github.com>
Date: Wed, 11 Mar 2026 19:25:27 +0000
Subject: [PATCH] fix shared page mention view for non-logged in users (#2008)
---
.../components/mention/mention-view.tsx | 79 +++++++++++++++----
.../components/subpages/subpages-view.tsx | 6 +-
2 files changed, 66 insertions(+), 19 deletions(-)
diff --git a/apps/client/src/features/editor/components/mention/mention-view.tsx b/apps/client/src/features/editor/components/mention/mention-view.tsx
index a874cdf4..561f3e0f 100644
--- a/apps/client/src/features/editor/components/mention/mention-view.tsx
+++ b/apps/client/src/features/editor/components/mention/mention-view.tsx
@@ -3,6 +3,7 @@ import { ActionIcon, Anchor, Text } from "@mantine/core";
import { IconFileDescription } from "@tabler/icons-react";
import { Link, useLocation, useNavigate, useParams } from "react-router-dom";
import { usePageQuery } from "@/features/page/queries/page-query.ts";
+import { useSharePageQuery } from "@/features/share/queries/share-query.ts";
import {
buildPageUrl,
buildSharedPageUrl,
@@ -13,17 +14,23 @@ import classes from "./mention.module.css";
export default function MentionView(props: NodeViewProps) {
const { node } = props;
const { label, entityType, entityId, slugId, anchorId } = node.attrs;
+ const isPageMention = entityType === "page";
const { spaceSlug, pageSlug } = useParams();
const { shareId } = useParams();
const navigate = useNavigate();
+
+ const location = useLocation();
+ const isShareRoute = location.pathname.startsWith("/share");
+
const {
data: page,
isLoading,
isError,
- } = usePageQuery({ pageId: entityType === "page" ? slugId : null });
+ } = usePageQuery({ pageId: isPageMention && !isShareRoute ? slugId : null });
- const location = useLocation();
- const isShareRoute = location.pathname.startsWith("/share");
+ const { data: sharedPage } = useSharePageQuery({
+ pageId: isPageMention && isShareRoute ? slugId : undefined,
+ });
const currentPageSlugId = extractPageSlugId(pageSlug);
const isSamePage = currentPageSlugId === slugId;
@@ -39,10 +46,12 @@ export default function MentionView(props: NodeViewProps) {
}
};
+ const sharePageTitle = sharedPage?.page?.title || label;
+
const shareSlugUrl = buildSharedPageUrl({
shareId,
pageSlugId: slugId,
- pageTitle: label,
+ pageTitle: sharePageTitle,
anchorId,
});
@@ -54,21 +63,59 @@ export default function MentionView(props: NodeViewProps) {
)}
- {entityType === "page" && isError && (
-
- {label}
-
- )}
-
- {entityType === "page" && !isError && (
+ {isPageMention && isShareRoute && (
+
+
+
+
+ {sharePageTitle}
+
+
+ )}
+
+ {isPageMention && !isShareRoute && isError && (
+
+
+
+
+
+ {label}
+
+
+ )}
+
+ {isPageMention && !isShareRoute && !isError && (
+ {
// If we're in a shared context, use the shared subpages