The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Add customIsActive logic
Steven Tey2b6babde689f
diff --git a/apps/web/ui/layout/sidebar/app-sidebar-nav.tsx b/apps/web/ui/layout/sidebar/app-sidebar-nav.tsxindex 9d5421e51f..1d0622a213 100644--- a/apps/web/ui/layout/sidebar/app-sidebar-nav.tsx+++ b/apps/web/ui/layout/sidebar/app-sidebar-nav.tsx@@ -103,6 +103,22 @@ const NAV_AREAS: SidebarNavAreas<SidebarNavData> = {name: "Links",icon: Hyperlink,href: `/${slug}/links${pathname === `/${slug}/links` ? "" : queryString}`,+ isActive: (pathname: string, href: string) => {+ const basePath = href.split("?")[0];++ // Exact match for the base links page+ if (pathname === basePath) return true;++ // Check if it's a link detail page (path segment after base contains a dot for domain)+ if (pathname.startsWith(basePath + "/")) {+ const nextSegment = pathname+ .slice(basePath.length + 1)+ .split("/")[0];+ return nextSegment.includes(".");+ }++ return false;+ },},{name: "Domains",diff --git a/apps/web/ui/layout/sidebar/sidebar-nav.tsx b/apps/web/ui/layout/sidebar/sidebar-nav.tsxindex 1ce740f61b..bb1ffda12f 100644--- a/apps/web/ui/layout/sidebar/sidebar-nav.tsx+++ b/apps/web/ui/layout/sidebar/sidebar-nav.tsx@@ -25,6 +25,7 @@ export type NavItemCommon = {name: string;href: `/${string}`;exact?: boolean;+ isActive?: (pathname: string, href: string) => boolean;};export type NavSubItemType = NavItemCommon;@@ -293,7 +294,7 @@ function NavGroupItem({}function NavItem({ item }: { item: NavItemType | NavSubItemType }) {- const { name, href, exact } = item;+ const { name, href, exact, isActive: customIsActive } = item;const Icon = "icon" in item ? item.icon : undefined;const items = "items" in item ? item.items : undefined;@@ -303,11 +304,15 @@ function NavItem({ item }: { item: NavItemType | NavSubItemType }) {const pathname = usePathname();const isActive = useMemo(() => {+ if (customIsActive) {+ return customIsActive(pathname, href);+ }+const hrefWithoutQuery = href.split("?")[0];return exact? pathname === hrefWithoutQuery: pathname.startsWith(hrefWithoutQuery);- }, [pathname, href, exact]);+ }, [pathname, href, exact, customIsActive]);return (<div>