diff --git a/packages/ui/app/src/components/FernLink.tsx b/packages/ui/app/src/components/FernLink.tsx index c27028c0c4..cdc010f5d7 100644 --- a/packages/ui/app/src/components/FernLink.tsx +++ b/packages/ui/app/src/components/FernLink.tsx @@ -1,8 +1,9 @@ import { ExternalLinkIcon } from "@radix-ui/react-icons"; -import { useAtomValue } from "jotai"; +import { atom, useAtomValue } from "jotai"; import Link from "next/link"; import { ReactElement, forwardRef, useEffect, useState, type ComponentProps } from "react"; import { format, parse, resolve, type UrlObject } from "url"; +import { useMemoOne } from "use-memo-one"; import { SLUG_ATOM, useDomain } from "../atoms"; interface FernLinkProps extends ComponentProps { @@ -34,8 +35,12 @@ export const FernLink = forwardRef( FernLink.displayName = "FernLink"; const FernRelativeLink = forwardRef>((props, ref) => { - const selectedSlug = useAtomValue(SLUG_ATOM); - const href = resolveRelativeUrl(`/${selectedSlug}`, formatUrlString(props.href)); + const href = useAtomValue( + useMemoOne( + () => atom((get) => resolveRelativeUrl(`/${get(SLUG_ATOM)}`, formatUrlString(props.href))), + [props.href], + ), + ); return ; }); diff --git a/packages/ui/app/src/sidebar/nodes/SidebarLinkNode.tsx b/packages/ui/app/src/sidebar/nodes/SidebarLinkNode.tsx index 463f6cbba8..ba6e9aa109 100644 --- a/packages/ui/app/src/sidebar/nodes/SidebarLinkNode.tsx +++ b/packages/ui/app/src/sidebar/nodes/SidebarLinkNode.tsx @@ -15,9 +15,8 @@ export function SidebarLinkNode({ node, depth, className }: SidebarLinkNodeProps className={className} depth={Math.max(depth - 1, 0)} title={node.title} - rightElement={} + rightElement={node.url.startsWith("http") && } href={node.url} - target={"_blank"} hidden={false} /> );