diff --git a/components/dashboard/DashboardShell.tsx b/components/dashboard/DashboardShell.tsx index 17160e8..5f301fb 100644 --- a/components/dashboard/DashboardShell.tsx +++ b/components/dashboard/DashboardShell.tsx @@ -2,12 +2,32 @@ import { useState, useCallback, useEffect, useRef } from 'react' import dynamic from 'next/dynamic' +import { usePathname } from 'next/navigation' import { formatUpdatedAgo } from '@ciphera-net/ui' import { SidebarSimple } from '@phosphor-icons/react' import { SidebarProvider, useSidebar } from '@/lib/sidebar-context' import { useRealtime } from '@/lib/swr/dashboard' import ContentHeader from './ContentHeader' +const PAGE_TITLES: Record = { + '': 'Dashboard', + journeys: 'Journeys', + funnels: 'Funnels', + behavior: 'Behavior', + search: 'Search', + cdn: 'CDN', + uptime: 'Uptime', + pagespeed: 'PageSpeed', + settings: 'Site Settings', +} + +function usePageTitle() { + const pathname = usePathname() + // pathname is /sites/:id or /sites/:id/section/... + const segment = pathname.replace(/^\/sites\/[^/]+\/?/, '').split('/')[0] + return PAGE_TITLES[segment] ?? segment.charAt(0).toUpperCase() + segment.slice(1) || 'Dashboard' +} + // Load sidebar only on the client — prevents SSR flash const Sidebar = dynamic(() => import('./Sidebar'), { ssr: false, @@ -37,16 +57,21 @@ function GlassTopBar({ siteId }: { siteId: string }) { return () => clearInterval(timer) }, [realtime]) + const pageTitle = usePageTitle() + return (
- {/* Collapse toggle — mirrors sidebar AppLauncher row sizing for pixel alignment */} - + {/* Left: collapse toggle + page title */} +
+ + {pageTitle} +
{/* Realtime indicator */} {lastUpdatedRef.current != null && (