Skip to content

Open source alternative to Semrush and Ahrefs

Show research results in one card and put back links above page titles (EVE-365) (#779)

Carter Smitha61e88e3f1e4
diff --git a/src/client/components/PageHeader.tsx b/src/client/components/PageHeader.tsx
index 17fe2926..eef19f05 100644
--- a/src/client/components/PageHeader.tsx
+++ b/src/client/components/PageHeader.tsx
@@ -3,18 +3,23 @@ import { createLink } from "@tanstack/react-router";
import { ChevronLeft } from "lucide-react";
import { cn } from "cn";
-/** The page title, with an optional subtitle and actions on the right. */
+/**
+ * The page title, with an optional subtitle and actions on the right. A
+ * `backLink` (a `BackLink` or `BackButton`) sits above the title.
+ */
export function PageHeader({
title,
description,
actions,
+ backLink,
}: {
title: ReactNode;
/** A subtitle, or metadata such as a `<dl>`. */
description?: ReactNode;
actions?: ReactNode;
+ backLink?: ReactNode;
}) {
- return (
+ const header = (
<div className="flex flex-wrap items-start justify-between gap-3">
<div className="min-w-0 flex-1 basis-64 space-y-1">
<h1 className="text-2xl font-semibold tracking-tight">{title}</h1>
@@ -29,6 +34,13 @@ export function PageHeader({
) : null}
</div>
);
+ if (!backLink) return header;
+ return (
+ <div className="space-y-3">
+ {backLink}
+ {header}
+ </div>
+ );
}
/** The heading of one section on a page, with an optional hint and action. */
@@ -52,19 +64,16 @@ export function SectionHeader({
);
}
+const BACK_LINK_CLASS =
+ "inline-flex items-center gap-1 text-sm text-muted-foreground transition-colors hover:text-foreground";
+
function BackLinkAnchor({
className,
children,
...props
}: ComponentProps<"a">) {
return (
- <a
- {...props}
- className={cn(
- "inline-flex items-center gap-1 text-sm text-muted-foreground transition-colors hover:text-foreground",
- className,
- )}
- >
+ <a {...props} className={cn(BACK_LINK_CLASS, className)}>
<ChevronLeft className="size-4" aria-hidden />
{children}
</a>
@@ -73,3 +82,21 @@ function BackLinkAnchor({
/** A router link back to the parent page, with a chevron before its label. */
export const BackLink = createLink(BackLinkAnchor);
+
+/** `BackLink` for a page whose way back is a callback, not a route. */
+export function BackButton({
+ className,
+ children,
+ ...props
+}: ComponentProps<"button">) {
+ return (
+ <button
+ type="button"
+ {...props}
+ className={cn(BACK_LINK_CLASS, "cursor-pointer", className)}
+ >
+ <ChevronLeft className="size-4" aria-hidden />
+ {children}
+ </button>
+ );
+}
diff --git a/src/client/components/RecentSearches.tsx b/src/client/components/RecentSearches.tsx
index b36cbffc..6cd63785 100644
--- a/src/client/components/RecentSearches.tsx
+++ b/src/client/components/RecentSearches.tsx
@@ -1,7 +1,7 @@
import type { ReactNode } from "react";
-import { ArrowLeft, Clock, History, X, type LucideIcon } from "lucide-react";
+import { Clock, History, X, type LucideIcon } from "lucide-react";
import { EmptyState } from "@/client/components/EmptyState";
-import { Button, buttonVariants } from "@/client/components/ui/button";
+import { Button } from "@/client/components/ui/button";
import { Card, CardContent, CardHeader } from "@/client/components/ui/card";
// Props for the caller's clickable element. Spread them onto a <Link> so
@@ -103,28 +103,3 @@ export function RecentSearches<TItem extends { timestamp: number }>({
</Card>
);
}
-
-// The "Recent searches" link that returns a research page to its list.
-export function RecentSearchesBackLink({
- render,
-}: {
- render: (props: ClickableProps) => ReactNode;
-}) {
- return (
- <div>
- {render({
- className: buttonVariants({
- variant: "ghost",
- size: "sm",
- className: "-ml-2.5 text-muted-foreground",
- }),
- children: (
- <>
- <ArrowLeft />
- Recent searches
- </>
- ),
- })}
- </div>
- );
-}
diff --git a/src/client/components/StatTile.tsx b/src/client/components/StatTile.tsx
index 42da0e07..1933a4a2 100644
--- a/src/client/components/StatTile.tsx
+++ b/src/client/components/StatTile.tsx
@@ -5,8 +5,7 @@ import { cn } from "cn";
*
* `delta` compares the value with the previous period and shows the percent
* change. It shows nothing when either side is missing or the previous value
- * is zero. `card` draws the tile as its own bordered box; without it the tile
- * sits bare inside another card.
+ * is zero.
*/
export function StatTile({
label,
@@ -14,7 +13,6 @@ export function StatTile({
tone,
delta,
hint,
- card = false,
}: {
label: string;
value: string;
@@ -22,16 +20,10 @@ export function StatTile({
tone?: "success" | "destructive";
delta?: { current: number | null; previous: number | null };
hint?: string;
- card?: boolean;
}) {
const percent = delta ? percentChange(delta.current, delta.previous) : null;
return (
- <div
- className={cn(
- "flex min-w-0 flex-col gap-1",
- card && "rounded-xl border border-border bg-card p-4 shadow-sm",
- )}
- >
+ <div className="flex min-w-0 flex-col gap-1">
<p className="text-xs font-medium tracking-wide text-muted-foreground uppercase">
{label}
</p>
diff --git a/src/client/features/ai-search/BrandLookupPage.tsx b/src/client/features/ai-search/BrandLookupPage.tsx
index 3455610e..64cc3239 100644
--- a/src/client/features/ai-search/BrandLookupPage.tsx
+++ b/src/client/features/ai-search/BrandLookupPage.tsx
@@ -7,10 +7,8 @@ import { useHostedPlanGate } from "@/client/features/billing/HostedPlanGate";
import { ResearchPageShell } from "@/client/features/ai-search/ResearchPageShell";
import { BrandLookupResults } from "@/client/features/ai-search/components/BrandLookupResults";
import { BrandLookupSearchCard } from "@/client/features/ai-search/components/BrandLookupSearchCard";
-import {
- RecentSearches,
- RecentSearchesBackLink,
-} from "@/client/components/RecentSearches";
+import { RecentSearches } from "@/client/components/RecentSearches";
+import { BackLink } from "@/client/components/PageHeader";
import { Badge } from "@/client/components/ui/badge";
import { useBrandLookupSearchHistory } from "@/client/hooks/useBrandLookupSearchHistory";
import {
@@ -257,18 +255,15 @@ export function BrandLookupPage({
})
}
backLink={
- <RecentSearchesBackLink
- render={(props) => (
- <Link
- from="/p/$projectId/brand-lookup"
- to="/p/$projectId/brand-lookup"
- params={{ projectId }}
- search={{ q: undefined, c: undefined, scope: undefined }}
- replace
- {...props}
- />
- )}
- />
+ <BackLink
+ from="/p/$projectId/brand-lookup"
+ to="/p/$projectId/brand-lookup"
+ params={{ projectId }}
+ search={{ q: undefined, c: undefined, scope: undefined }}
+ replace
+ >
+ Recent searches
+ </BackLink>
}
renderResults={(result) => (
<BrandLookupResults result={result} projectId={projectId} />
diff --git a/src/client/features/ai-search/PromptExplorerPage.tsx b/src/client/features/ai-search/PromptExplorerPage.tsx
index b2ae0693..9d2e9b66 100644
--- a/src/client/features/ai-search/PromptExplorerPage.tsx
+++ b/src/client/features/ai-search/PromptExplorerPage.tsx
@@ -8,10 +8,8 @@ import { useHostedPlanGate } from "@/client/features/billing/HostedPlanGate";
import { ResearchPageShell } from "@/client/features/ai-search/ResearchPageShell";
import { PromptExplorerForm } from "@/client/features/ai-search/components/PromptExplorerForm";
import { PromptExplorerResults } from "@/client/features/ai-search/components/PromptExplorerResults";
-import {
- RecentSearches,
- RecentSearchesBackLink,
-} from "@/client/components/RecentSearches";
+import { RecentSearches } from "@/client/components/RecentSearches";
+import { BackLink } from "@/client/components/PageHeader";
import { formatModelLabel } from "@/client/features/ai-search/platformLabels";
import { usePromptExplorerSearchHistory } from "@/client/hooks/usePromptExplorerSearchHistory";
import {
@@ -194,18 +192,15 @@ export function PromptExplorerPage({ projectId, urlState, onSubmit }: Props) {
})
}
backLink={
- <RecentSearchesBackLink
- render={(props) => (
- <Link
- from="/p/$projectId/prompt-explorer"
- to="/p/$projectId/prompt-explorer"
- params={{ projectId }}
- search={{}}
- replace
- {...props}
- />
- )}
- />
+ <BackLink
+ from="/p/$projectId/prompt-explorer"
+ to="/p/$projectId/prompt-explorer"
+ params={{ projectId }}
+ search={{}}
+ replace
+ >
+ Recent searches
+ </BackLink>
}
renderResults={(result) => <PromptExplorerResults result={result} />}
history={
diff --git a/src/client/features/ai-search/ResearchPageShell.tsx b/src/client/features/ai-search/ResearchPageShell.tsx
index e818fd1b..9f3f4a1a 100644
--- a/src/client/features/ai-search/ResearchPageShell.tsx
+++ b/src/client/features/ai-search/ResearchPageShell.tsx
@@ -90,7 +90,11 @@ export function ResearchPageShell<TData>({
return (
<div className="overflow-auto px-4 py-4 pb-24 md:px-6 md:py-6 md:pb-8">
<div className="mx-auto max-w-7xl space-y-4">
- <PageHeader title={title} description={description} />
+ <PageHeader
+ title={title}
+ description={description}
+ backLink={resultData && !isLoading ? backLink : undefined}
+ />
{planStatus === "loading" ? (
<PageLoading />
@@ -145,10 +149,7 @@ export function ResearchPageShell<TData>({
</Card>
</div>
) : resultData ? (
- <>
- {backLink}
- {renderResults(resultData)}
- </>
+ renderResults(resultData)
) : !errorMessage ? (
history
) : null}
diff --git a/src/client/features/ai-search/components/BrandLookupResults.tsx b/src/client/features/ai-search/components/BrandLookupResults.tsx
index d147f289..a46be57d 100644
--- a/src/client/features/ai-search/components/BrandLookupResults.tsx
+++ b/src/client/features/ai-search/components/BrandLookupResults.tsx
@@ -1,13 +1,7 @@
import { Info, TriangleAlert } from "lucide-react";
import { Alert, AlertTitle } from "@/client/components/ui/alert";
import { Badge } from "@/client/components/ui/badge";
-import {
- Card,
- CardAction,
- CardContent,
- CardHeader,
- CardTitle,
-} from "@/client/components/ui/card";
+import { Card } from "@/client/components/ui/card";
import {
Tooltip,
TooltipContent,
@@ -82,16 +76,19 @@ export function BrandLookupResults({ result, projectId }: Props) {
const sov = result.shareOfVoice;
return (
- <div className="space-y-4">
+ <Card className="gap-0 py-0">
<BrandHeader result={result} />
- {/* One shared grid so the cards align by construction: stats left, trend
- right, Share of Voice flowing into the next free half-width cell —
- whichever of trend/SoV is absent, the rest stay column-aligned. A
- lone stats card keeps full width instead of half a grid. */}
+ {/* One shared grid so the panels align by construction: stats left,
+ trend right, Share of Voice flowing into the next free half-width
+ cell — whichever of trend/SoV is absent, the rest stay
+ column-aligned. A lone stats panel keeps full width instead of half a
+ grid. */}
<div
className={
- hasTrendData || sov ? "grid gap-4 lg:grid-cols-2" : undefined
+ hasTrendData || sov
+ ? "grid gap-3 px-4 pb-4 lg:grid-cols-2"
+ : "px-4 pb-4"
}
>
<StatsCard result={result} />
@@ -104,23 +101,23 @@ export function BrandLookupResults({ result, projectId }: Props) {
) : null}
</div>
- <CitationTabsCard result={result} projectId={projectId} />
- </div>
+ <div className="px-4 pb-4">
+ <CitationTabsCard result={result} projectId={projectId} />
+ </div>
+ </Card>
);
}
function BrandHeader({ result }: { result: BrandLookupResult }) {
return (
- <section className="flex flex-wrap items-baseline justify-between gap-2">
- <div className="flex flex-wrap items-baseline gap-3">
- <h2 className="text-3xl font-semibold tracking-tight">
+ <section className="px-4 pt-4 pb-3">
+ <div className="flex flex-wrap items-center gap-2">
+ <h2 className="text-lg font-semibold break-all">
{result.resolvedTarget}
</h2>
<Badge variant="secondary">{result.detectedTargetType}</Badge>
{result.scope ? (
- <Badge variant="secondary">
- {RESEARCH_SCOPE_LABELS[result.scope]}
- </Badge>
+ <Badge variant="outline">{RESEARCH_SCOPE_LABELS[result.scope]}</Badge>
) : null}
</div>
<p className="text-xs text-muted-foreground">
@@ -132,7 +129,7 @@ function BrandHeader({ result }: { result: BrandLookupResult }) {
function StatsCard({ result }: { result: BrandLookupResult }) {
return (
- <Card className="py-0">
+ <div className="rounded-lg border border-border">
<div className="flex h-full flex-col divide-y divide-border">
<StatBlock
label="Mentions"
@@ -151,7 +148,7 @@ function StatsCard({ result }: { result: BrandLookupResult }) {
isDomainLevel={result.aggregatesAreDomainLevel}
/>
</div>
- </Card>
+ </div>
);
}
@@ -221,21 +218,17 @@ function PlatformStatRow({
function MentionTrendCard({ result }: { result: BrandLookupResult }) {
return (
- <Card>
- <CardHeader className="border-b">
- <CardTitle>
- <h3 className="text-sm">Mention trend (last 12 months)</h3>
- </CardTitle>
+ <div className="rounded-lg border border-border">
+ <div className="flex items-center justify-between gap-2 border-b border-border px-4 py-3">
+ <h3 className="text-sm font-medium">Mention trend (last 12 months)</h3>
{result.aggregatesAreDomainLevel ? (
- <CardAction>
- <DomainLevelBadge tooltip={DOMAIN_LEVEL_TIP} />
- </CardAction>
+ <DomainLevelBadge tooltip={DOMAIN_LEVEL_TIP} />
) : null}
- </CardHeader>
- <CardContent>
+ </div>
+ <div className="p-4">
<BrandLookupMentionTrendCard result={result} />
- </CardContent>
- </Card>
+ </div>
+ </div>
);
}
diff --git a/src/client/features/ai-search/components/BrandLookupShareOfVoice.tsx b/src/client/features/ai-search/components/BrandLookupShareOfVoice.tsx
index be256c96..ef43fa78 100644
--- a/src/client/features/ai-search/components/BrandLookupShareOfVoice.tsx
+++ b/src/client/features/ai-search/components/BrandLookupShareOfVoice.tsx
@@ -1,11 +1,5 @@
import { cn } from "cn";
import { Badge } from "@/client/components/ui/badge";
-import {
- Card,
- CardAction,
- CardHeader,
- CardTitle,
-} from "@/client/components/ui/card";
import { Progress } from "@/client/components/ui/progress";
import { DomainLevelBadge } from "@/client/features/ai-search/components/DomainLevelBadge";
import {
@@ -38,23 +32,23 @@ export function BrandLookupShareOfVoice({
);
return (
- <Card className="h-full gap-0 py-0">
- <CardHeader className="border-b py-3">
- <CardTitle className="flex items-center gap-2">
- <h3 className="text-sm">Share of Voice</h3>
+ <div className="flex h-full flex-col rounded-lg border border-border">
+ <div className="flex items-center justify-between gap-2 border-b border-border px-4 py-3">
+ <div className="flex items-center gap-2">
+ <h3 className="text-sm font-medium">Share of Voice</h3>
{isDomainLevel ? (
<DomainLevelBadge tooltip="Share of Voice compares whole domains — it is not narrowed to the page or folder you searched." />
) : null}
- </CardTitle>
+ </div>
{target ? (
- <CardAction className="self-center text-xs text-muted-foreground">
+ <span className="text-xs text-muted-foreground">
<span className="font-medium text-foreground">{target.label}</span>{" "}
{target.sharePct == null
? "· no comparable data"
: `· ${Math.round(target.sharePct)}%`}
- </CardAction>
+ </span>
) : null}
- </CardHeader>
+ </div>
<ul className="flex-1 divide-y divide-border">
{shareOfVoice.entries.map((entry, index) => (
@@ -74,7 +68,7 @@ export function BrandLookupShareOfVoice({
{shareOfVoice.platforms.map(formatPlatformLabel).join(" and ")} · bars
relative to the leader.
</p>
- </Card>
+ </div>
);
}
diff --git a/src/client/features/audit/AuditDetail.tsx b/src/client/features/audit/AuditDetail.tsx
index 10ed3d87..510b3650 100644
--- a/src/client/features/audit/AuditDetail.tsx
+++ b/src/client/features/audit/AuditDetail.tsx
@@ -1,4 +1,5 @@
-import { AlertCircle, ChevronLeft } from "lucide-react";
+import { AlertCircle } from "lucide-react";
+import { BackButton } from "@/client/components/PageHeader";
import { useQuery } from "@tanstack/react-query";
import { QueryError, QueryState } from "@/client/components/QueryState";
import { PageLoading } from "@/client/components/Spinner";
@@ -8,7 +9,6 @@ import {
AlertTitle,
} from "@/client/components/ui/alert";
import { Badge } from "@/client/components/ui/badge";
-import { Button } from "@/client/components/ui/button";
import {
Card,
CardAction,
@@ -84,15 +84,12 @@ export function AuditDetail({
return (
<div className="px-4 py-4 md:px-6 md:py-6">
<div className="mx-auto max-w-7xl space-y-4">
+ <BackButton onClick={onBack}>All audits</BackButton>
<QueryError
fallback="We could not load this audit. It may have been deleted."
onRetry={() => void statusQuery.refetch()}
isRetrying={statusQuery.isFetching}
/>
- <Button variant="ghost" size="sm" onClick={onBack}>
- <ChevronLeft data-icon="inline-start" />
- Back to audits
- </Button>
</div>
</div>
);
@@ -114,25 +111,19 @@ export function AuditDetail({
return (
<div className="px-4 py-4 md:px-6 md:py-6 pb-24 md:pb-8 overflow-auto">
<div className="mx-auto max-w-7xl space-y-4">
- <div className="space-y-1">
- <Button
- variant="ghost"
- size="sm"
- className="-ml-2.5"
- onClick={onBack}
- >
- <ChevronLeft data-icon="inline-start" />
- All audits
- </Button>
- <div className="flex flex-wrap items-center gap-x-3 gap-y-1">
- <h1 className="text-2xl font-semibold">
- {extractHostname(status.startUrl)}
- </h1>
- {!isRunning && <StatusBadge status={status.status} />}
+ <div className="space-y-3">
+ <BackButton onClick={onBack}>All audits</BackButton>
+ <div className="space-y-1">
+ <div className="flex flex-wrap items-center gap-x-3 gap-y-1">
+ <h1 className="text-2xl font-semibold tracking-tight">
+ {extractHostname(status.startUrl)}
+ </h1>
+ {!isRunning && <StatusBadge status={status.status} />}
+ </div>
+ <p className="text-sm text-muted-foreground">
+ Site audit &middot; Started {formatStartedAt(status.startedAt)}
+ </p>
</div>
- <p className="text-sm text-muted-foreground">
- Site audit &middot; Started {formatStartedAt(status.startedAt)}
- </p>
</div>
{isRunning && (
diff --git a/src/client/features/backlinks/BacklinksOverviewPanels.tsx b/src/client/features/backlinks/BacklinksOverviewPanels.tsx
index 2940c8bd..9708a8bc 100644
--- a/src/client/features/backlinks/BacklinksOverviewPanels.tsx
+++ b/src/client/features/backlinks/BacklinksOverviewPanels.tsx
@@ -1,15 +1,6 @@
-import { Link } from "@tanstack/react-router";
import { Info } from "lucide-react";
import { Alert, AlertDescription } from "@/client/components/ui/alert";
import { Badge } from "@/client/components/ui/badge";
-import {
- Card,
- CardContent,
- CardDescription,
- CardHeader,
- CardTitle,
-} from "@/client/components/ui/card";
-import { RecentSearchesBackLink } from "@/client/components/RecentSearches";
import { RESEARCH_SCOPE_LABELS } from "@/shared/researchScope";
import { HelpLabel } from "@/client/components/HelpLabel";
import {
@@ -21,67 +12,58 @@ import { formatRelativeTimestamp } from "./backlinksPageUtils";
type SummaryStat = { label: string; value: string; description: string };
+const SCOPE_NOTES: Partial<Record<BacklinksOverviewData["scope"], string>> = {
+ exact_url:
+ "Showing backlinks for this exact page. Switch the scope to Domain or Subdomains for site-wide results — trend charts need one of those.",
+ subfolder:
+ "Showing backlinks pointing into this subfolder. Counts come from filtered backlink totals; rank, trends, and the referring-domains breakdown need Domain or Subdomains scope.",
+};
+
+export function BacklinksScopeAlert({
+ scope,
+}: {
+ scope: BacklinksOverviewData["scope"];
+}) {
+ const note = SCOPE_NOTES[scope];
+ if (!note) return null;
+ return (
+ <Alert variant="info">
+ <Info />
+ <AlertDescription className="text-foreground">{note}</AlertDescription>
+ </Alert>
+ );
+}
+
+/** The header and overview sections at the top of the results card. */
export function BacklinksOverviewPanels({
- projectId,
data,
summaryStats,
}: {
- projectId: string;
data: BacklinksOverviewData;
summaryStats: SummaryStat[];
}) {
return (
<>
- <RecentSearchesBackLink
- render={(props) => (
- <Link
- to="/p/$projectId/backlinks"
- params={{ projectId }}
- search={{
- target: undefined,
- scope: undefined,
- tab: undefined,
- page: undefined,
- size: undefined,
- sort: undefined,
- order: undefined,
- }}
- replace
- {...props}
- />
- )}
- />
- <div className="flex flex-wrap items-center gap-2 text-sm text-muted-foreground">
- <Badge variant="outline">{RESEARCH_SCOPE_LABELS[data.scope]}</Badge>
- <span>Target: {data.displayTarget}</span>
- <span>-</span>
- <span>Updated {formatRelativeTimestamp(data.fetchedAt)}</span>
- {/* history/live can't exclude subdomains, so say so rather than imply
- the charts match the domain-scoped totals. */}
- {data.scope === "domain" ? (
- <span>- Trends include subdomains</span>
- ) : null}
+ <div className="px-4 pt-4 pb-3">
+ <div className="flex flex-wrap items-center gap-2">
+ <h2 className="text-lg font-semibold break-all">
+ {data.displayTarget}
+ </h2>
+ <Badge variant="outline">{RESEARCH_SCOPE_LABELS[data.scope]}</Badge>
+ </div>
+ <p className="text-xs text-muted-foreground">
+ Updated {formatRelativeTimestamp(data.fetchedAt)} &middot; Overview
+ metrics cover the full target, before table filters
+ {/* history/live can't exclude subdomains, so say so rather than
+ imply the charts match the domain-scoped totals. */}
+ {data.scope === "domain" ? (
+ <> &middot; Trends include subdomains</>
+ ) : null}
+ </p>
+ </div>
+ <div className="px-4 pb-4">
+ <OverviewGrid data={data} summaryStats={summaryStats} />
</div>
- <OverviewGrid data={data} summaryStats={summaryStats} />
- {data.scope === "exact_url" ? (
- <Alert variant="info">
- <Info />
- <AlertDescription className="text-foreground">
- Showing backlinks for this exact page. Switch the scope to Domain or
- Subdomains for site-wide results — trend charts need one of those.
- </AlertDescription>
- </Alert>
- ) : null}
- {data.scope === "subfolder" ? (
- <Alert variant="info">
- <Info />
- <AlertDescription className="text-foreground">
- Showing backlinks pointing into this subfolder. Counts come from
- filtered backlink totals; rank, trends, and the referring-domains
- breakdown need Domain or Subdomains scope.
- </AlertDescription>
- </Alert>
- ) : null}
</>
);
}
@@ -100,27 +82,12 @@ function OverviewGrid({
<div
className={`grid grid-cols-1 gap-3 ${domainScope ? "md:grid-cols-2 xl:grid-cols-3" : ""}`}
>
- <SummaryStatsGrid data={data} summaryStats={summaryStats} />
- {domainScope ? <TrendPanels data={data} /> : null}
- </div>
- );
-}
-
-function SummaryStatsGrid({
- data,
- summaryStats,
-}: {
- data: BacklinksOverviewData;
- summaryStats: SummaryStat[];
-}) {
- const hasTrendPanels = data.scope === "domain" || data.scope === "subdomains";
-
- return (
- <Card
- className={hasTrendPanels ? "md:col-span-2 xl:col-span-1" : undefined}
- >
- <CardContent className="xl:h-full">
- <div className="grid grid-cols-2 gap-x-6 gap-y-5 xl:gap-y-6">
+ <div
+ className={`rounded-lg border border-border p-3 ${domainScope ? "md:col-span-2 xl:col-span-1" : ""}`}
+ >
+ <div
+ className={`grid grid-cols-2 gap-x-6 gap-y-5 xl:gap-y-6 ${domainScope ? "" : "md:grid-cols-4"}`}
+ >
{summaryStats.map((item) => (
<div key={item.label}>
<div className="text-xs tracking-wide text-muted-foreground uppercase">
@@ -130,31 +97,28 @@ function SummaryStatsGrid({
</div>
))}
</div>
- </CardContent>
- </Card>
- );
-}
-
-function TrendPanels({ data }: { data: BacklinksOverviewData }) {
- return (
- <>
- <TrendCard
- title="Backlink growth"
- description="Backlinks and referring domains over the last year"
- >
- <BacklinksTrendChart data={data.trends} />
- </TrendCard>
- <TrendCard
- title="New vs lost"
- description="Backlink acquisition and attrition"
- >
- <BacklinksNewLostChart data={data.newLostTrends} />
- </TrendCard>
- </>
+ </div>
+ {domainScope ? (
+ <>
+ <TrendPanel
+ title="Backlink growth"
+ description="Backlinks and referring domains over the last year"
+ >
+ <BacklinksTrendChart data={data.trends} />
+ </TrendPanel>
+ <TrendPanel
+ title="New vs lost"
+ description="Backlink acquisition and attrition"
+ >
+ <BacklinksNewLostChart data={data.newLostTrends} />
+ </TrendPanel>
+ </>
+ ) : null}
+ </div>
);
}
-function TrendCard({
+function TrendPanel({
children,
description,
title,
@@ -164,14 +128,12 @@ function TrendCard({
title: string;
}) {
return (
- <Card className="gap-2">
- <CardHeader>
- <CardTitle className="text-sm font-medium">
- <h2>{title}</h2>
- </CardTitle>
- <CardDescription className="text-xs">{description}</CardDescription>
- </CardHeader>
- <CardContent>{children}</CardContent>
- </Card>
+ <div className="space-y-2 rounded-lg border border-border p-3">
+ <div>
+ <h3 className="text-sm font-medium">{title}</h3>
+ <p className="text-xs text-muted-foreground">{description}</p>
+ </div>
+ {children}
+ </div>
);
}
diff --git a/src/client/features/backlinks/BacklinksPage.tsx b/src/client/features/backlinks/BacklinksPage.tsx
index 6b94d321..3c146f0a 100644
--- a/src/client/features/backlinks/BacklinksPage.tsx
+++ b/src/client/features/backlinks/BacklinksPage.tsx
@@ -1,6 +1,6 @@
import { useCallback, useMemo } from "react";
import type { SortingState, Updater } from "@tanstack/react-table";
-import { PageHeader } from "@/client/components/PageHeader";
+import { BackLink, PageHeader } from "@/client/components/PageHeader";
import { BacklinksSearchCard } from "./BacklinksSearchCard";
import { BacklinksBody } from "./BacklinksPageContent";
import type { BacklinksPageProps } from "./backlinksPageTypes";
@@ -108,6 +108,26 @@ export function BacklinksPage({
<PageHeader
title="Backlinks"
description="Understand who links to a site, what changed recently, and which pages attract links."
+ backLink={
+ searchState.target ? (
+ <BackLink
+ to="/p/$projectId/backlinks"
+ params={{ projectId }}
+ search={{
+ target: undefined,
+ scope: undefined,
+ tab: undefined,
+ page: undefined,
+ size: undefined,
+ sort: undefined,
+ order: undefined,
+ }}
+ replace
+ >
+ Recent searches
+ </BackLink>
+ ) : undefined
+ }
/>
<BacklinksSearchCard
diff --git a/src/client/features/backlinks/BacklinksPageCharts.tsx b/src/client/features/backlinks/BacklinksPageCharts.tsx
index 58dbb006..54930238 100644
--- a/src/client/features/backlinks/BacklinksPageCharts.tsx
+++ b/src/client/features/backlinks/BacklinksPageCharts.tsx
@@ -140,7 +140,7 @@ export function BacklinksNewLostChart({
function EmptyChartState() {
return (
- <div className="flex h-56 items-center justify-center rounded-xl border border-dashed border-border text-sm text-muted-foreground">
+ <div className="flex h-56 items-center justify-center text-sm text-muted-foreground">
Not enough historical data yet.
</div>
);
diff --git a/src/client/features/backlinks/BacklinksPageContent.tsx b/src/client/features/backlinks/BacklinksPageContent.tsx
index 36f475b1..182626f4 100644
--- a/src/client/features/backlinks/BacklinksPageContent.tsx
+++ b/src/client/features/backlinks/BacklinksPageContent.tsx
@@ -2,7 +2,10 @@ import { useMemo } from "react";
import { Link } from "@tanstack/react-router";
import { Link2 } from "lucide-react";
import type { OnChangeFn, SortingState } from "@tanstack/react-table";
-import { BacklinksOverviewPanels } from "./BacklinksOverviewPanels";
+import {
+ BacklinksOverviewPanels,
+ BacklinksScopeAlert,
+} from "./BacklinksOverviewPanels";
import { BacklinksResultsCard } from "./BacklinksPageSections";
import {
BacklinksErrorState,
@@ -18,6 +21,7 @@ import type { BacklinksDomainExpansion } from "./useBacklinksDomainExpansion";
import type { BacklinksFiltersState } from "./useBacklinksFilters";
import type { BacklinksPageData } from "./useBacklinksPageData";
import { SearchTabStrip } from "@/client/features/search-tabs/SearchTabStrip";
+import { Card } from "@/client/components/ui/card";
import { RecentSearches } from "@/client/components/RecentSearches";
import {
RESEARCH_SCOPE_LABELS,
@@ -79,7 +83,7 @@ export function BacklinksBody({
() => buildSummaryStats(overviewData),
[overviewData],
);
- const tabStrip = (
+ const tabControls = (
<SearchTabStrip
projectId={projectId}
activeTabId={searchTabs.activeTabId}
@@ -127,7 +131,7 @@ export function BacklinksBody({
if (data.overviewQuery.isPending) {
return (
<>
- {tabStrip}
+ {tabControls}
<BacklinksLoadingState />
</>
);
@@ -136,7 +140,7 @@ export function BacklinksBody({
if (!overviewData) {
return (
<>
- {tabStrip}
+ {tabControls}
<BacklinksErrorState
errorMessage={data.overviewErrorMessage}
onRetry={() => void data.overviewQuery.refetch()}
@@ -148,56 +152,59 @@ export function BacklinksBody({
return (
<>
- {tabStrip}
- <p className="text-xs text-muted-foreground">
- Overview metrics cover the full target, before table filters.
- </p>
- <BacklinksOverviewPanels
- projectId={projectId}
- data={overviewData}
- summaryStats={summaryStats}
- />
- <BacklinksResultsCard
- projectId={projectId}
- activeTab={searchState.tab}
- scope={searchState.scope}
- tabRows={tabRows}
- filters={filters}
- sorting={sorting}
- view={searchState.view}
- hideSpam={!searchState.includeSpam}
- onHideSpamChange={onHideSpamChange}
- domainExpansion={domainExpansion}
- isTabLoading={
- data.activeTabQuery.isPending && !data.activeTabFilterError
- }
- // A failed refetch keeps the loaded rows; a filter budget error hides
- // them because the query never ran for the current filters.
- showTable={activeTabPage !== undefined && !data.activeTabFilterError}
- tabErrorMessage={data.activeTabErrorMessage}
- tabError={
- data.activeTabFilterError ? undefined : data.activeTabQuery.error
- }
- onRetryTab={
- data.activeTabFilterError
- ? undefined
- : () => void data.activeTabQuery.refetch()
- }
- isTabRetrying={data.activeTabQuery.isFetching}
- exportTarget={overviewData.displayTarget || searchState.target}
- pagination={{
- page: searchState.page,
- pageSize: searchState.pageSize,
- totalCount: activeTabPage?.totalCount ?? null,
- hasNextPage: activeTabPage?.hasMore ?? false,
- isFetching: data.activeTabQuery.isFetching,
- }}
- onPageChange={onPageChange}
- onPageSizeChange={onPageSizeChange}
- onSortingChange={onSortingChange}
- onTabChange={onTabChange}
- onViewChange={onViewChange}
- />
+ {tabControls}
+ <BacklinksScopeAlert scope={overviewData.scope} />
+ <Card className="gap-0 py-0">
+ <BacklinksOverviewPanels
+ data={overviewData}
+ summaryStats={summaryStats}
+ />
+ <div className="px-4 pb-4">
+ <BacklinksResultsCard
+ projectId={projectId}
+ activeTab={searchState.tab}
+ scope={searchState.scope}
+ tabRows={tabRows}
+ filters={filters}
+ sorting={sorting}
+ view={searchState.view}
+ hideSpam={!searchState.includeSpam}
+ onHideSpamChange={onHideSpamChange}
+ domainExpansion={domainExpansion}
+ isTabLoading={
+ data.activeTabQuery.isPending && !data.activeTabFilterError
+ }
+ // A failed refetch keeps the loaded rows; a filter budget error hides
+ // them because the query never ran for the current filters.
+ showTable={
+ activeTabPage !== undefined && !data.activeTabFilterError
+ }
+ tabErrorMessage={data.activeTabErrorMessage}
+ tabError={
+ data.activeTabFilterError ? undefined : data.activeTabQuery.error
+ }
+ onRetryTab={
+ data.activeTabFilterError
+ ? undefined
+ : () => void data.activeTabQuery.refetch()
+ }
+ isTabRetrying={data.activeTabQuery.isFetching}
+ exportTarget={overviewData.displayTarget || searchState.target}
+ pagination={{
+ page: searchState.page,
+ pageSize: searchState.pageSize,
+ totalCount: activeTabPage?.totalCount ?? null,
+ hasNextPage: activeTabPage?.hasMore ?? false,
+ isFetching: data.activeTabQuery.isFetching,
+ }}
+ onPageChange={onPageChange}
+ onPageSizeChange={onPageSizeChange}
+ onSortingChange={onSortingChange}
+ onTabChange={onTabChange}
+ onViewChange={onViewChange}
+ />
+ </div>
+ </Card>
</>
);
}
diff --git a/src/client/features/backlinks/BacklinksPageStates.tsx b/src/client/features/backlinks/BacklinksPageStates.tsx
index ad8467d9..c6432113 100644
--- a/src/client/features/backlinks/BacklinksPageStates.tsx
+++ b/src/client/features/backlinks/BacklinksPageStates.tsx
@@ -1,32 +1,42 @@
import { ErrorState } from "@/client/components/ErrorState";
-import { SkeletonStatGrid } from "@/client/components/SkeletonPresets";
-import { Card, CardContent } from "@/client/components/ui/card";
+import { SkeletonTableRows } from "@/client/components/SkeletonPresets";
+import { Card } from "@/client/components/ui/card";
import { Skeleton } from "@/client/components/ui/skeleton";
export function BacklinksLoadingState() {
return (
- <div className="space-y-3">
- <SkeletonStatGrid
- count={8}
- className="grid-cols-1 md:grid-cols-2 xl:grid-cols-4"
- />
- <div className="grid grid-cols-1 gap-3 xl:grid-cols-2">
- {Array.from({ length: 2 }).map((_, index) => (
- <Card key={index}>
- <CardContent className="space-y-3">
- <Skeleton className="h-4 w-32" />
- <Skeleton className="h-64 w-full" />
- </CardContent>
- </Card>
+ <Card className="gap-0 py-0" aria-busy>
+ <div className="space-y-2 px-4 pt-4 pb-3">
+ <Skeleton className="h-6 w-48" />
+ <Skeleton className="h-3 w-80" />
+ </div>
+ <div className="grid grid-cols-1 gap-3 px-4 pb-4 md:grid-cols-2 xl:grid-cols-3">
+ <div className="grid grid-cols-2 gap-x-6 gap-y-5 rounded-lg border border-border p-3 md:col-span-2 xl:col-span-1">
+ {Array.from({ length: 8 }, (_, index) => (
+ <div key={index} className="space-y-2">
+ <Skeleton className="h-3 w-24" />
+ <Skeleton className="h-7 w-16" />
+ </div>
+ ))}
+ </div>
+ {Array.from({ length: 2 }, (_, index) => (
+ <div
+ key={index}
+ className="space-y-3 rounded-lg border border-border p-3"
+ >
+ <Skeleton className="h-4 w-32" />
+ <Skeleton className="h-56 w-full" />
+ </div>
))}
</div>
- <Card>
- <CardContent className="space-y-3">
- <Skeleton className="h-8 w-60" />
- <Skeleton className="h-80 w-full" />
- </CardContent>
- </Card>
- </div>
+ <div className="px-4 pb-4">
+ <div className="space-y-4 rounded-xl border border-border p-4">
+ <Skeleton className="h-6 w-72" />
+ <Skeleton className="h-4 w-96" />
+ <SkeletonTableRows />
+ </div>
+ </div>
+ </Card>
);
}
diff --git a/src/client/features/domain/DomainOverviewPage.tsx b/src/client/features/domain/DomainOverviewPage.tsx
index b93df02b..2481b569 100644
--- a/src/client/features/domain/DomainOverviewPage.tsx
+++ b/src/client/features/domain/DomainOverviewPage.tsx
@@ -2,9 +2,10 @@
import { useCallback, useEffect, useMemo, useRef, type FormEvent } from "react";
import { useForm, useStore } from "@tanstack/react-form";
import { Globe, Info } from "lucide-react";
-import { PageHeader } from "@/client/components/PageHeader";
+import { BackButton, PageHeader } from "@/client/components/PageHeader";
import { Alert, AlertDescription } from "@/client/components/ui/alert";
import { Badge } from "@/client/components/ui/badge";
+import { Card } from "@/client/components/ui/card";
import { DataTableTabs } from "@/client/components/table/DataTableToolbar";
import { TabsTrigger } from "@/client/components/ui/tabs";
import {
@@ -23,10 +24,7 @@ import {
} from "@/client/features/domain/domainSearchValidation";
import { useDomainOverviewQuery } from "@/client/features/domain/hooks/useDomainOverviewQuery";
import { DomainOverviewLoadingState } from "@/client/features/domain/components/DomainOverviewLoadingState";
-import {
- RecentSearches,
- RecentSearchesBackLink,
-} from "@/client/components/RecentSearches";
+import { RecentSearches } from "@/client/components/RecentSearches";
import { QueryError } from "@/client/components/QueryState";
import { DomainSearchCard } from "@/client/features/domain/components/DomainSearchCard";
import { KeywordsTab } from "@/client/features/domain/components/KeywordsTab";
@@ -537,28 +535,14 @@ export function DomainOverviewPage({
) : null;
const tabControls = routeState.domain ? (
- <div className="flex flex-col gap-2">
- <RecentSearchesBackLink
- render={(props) => (
- <button
- type="button"
- onClick={() => {
- searchTabs.setActiveTab(null);
- onShowRecentSearches();
- }}
- {...props}
- />
- )}
- />
- <SearchTabStrip
- projectId={projectId}
- activeTabId={searchTabs.activeTabId}
- tabs={searchTabs.tabs}
- onSelect={searchTabs.selectTab}
- onClose={searchTabs.closeTab}
- onViewed={searchTabs.markTabViewed}
- />
- </div>
+ <SearchTabStrip
+ projectId={projectId}
+ activeTabId={searchTabs.activeTabId}
+ tabs={searchTabs.tabs}
+ onSelect={searchTabs.selectTab}
+ onClose={searchTabs.closeTab}
+ onViewed={searchTabs.markTabViewed}
+ />
) : null;
return (
@@ -567,6 +551,18 @@ export function DomainOverviewPage({
<PageHeader
title="Domain Overview"
description="Analyze any domain's SEO profile: traffic, keywords, and backlinks."
+ backLink={
+ routeState.domain ? (
+ <BackButton
+ onClick={() => {
+ searchTabs.setActiveTab(null);
+ onShowRecentSearches();
+ }}
+ >
+ Recent searches
+ </BackButton>
+ ) : undefined
+ }
/>
<DomainSearchCard
@@ -616,33 +612,6 @@ export function DomainOverviewPage({
<>
{tabControls}
{overviewError}
- <div className="flex flex-wrap items-center gap-2">
- <Badge variant="secondary">{state.overview.displayTarget}</Badge>
- <Badge variant="outline">
- {RESEARCH_SCOPE_LABELS[state.overview.scope]}
- </Badge>
- </div>
- <div className="grid grid-cols-1 md:grid-cols-2 gap-3">
- <StatTile
- card
- label="Estimated Organic Traffic"
- value={formatMetric(
- state.overview.organicTraffic,
- state.overview.hasData,
- )}
- hint={overviewMetricsHint}
- />
- <StatTile
- card
- label="Organic Keywords"
- value={formatMetric(
- state.overview.organicKeywords,
- state.overview.hasData,
- )}
- hint={overviewMetricsHint}
- />
- </div>
-
{!state.overview.hasData ? (
<Alert variant="info">
<Info />
@@ -653,34 +622,67 @@ export function DomainOverviewPage({
</Alert>
) : null}
- {routeState.tab === "pages" ? (
- <PagesTab
- projectId={projectId}
- target={state.overview.displayTarget}
- hostname={state.overview.domain}
- scope={state.overview.scope}
- routeState={routeState}
- tabs={tabs}
- setSearchParams={state.setSearchParams}
- onSortClick={state.handleSortColumnClick}
- onPageChange={state.goToPage}
- onPageSizeChange={state.setPageSize}
- />
- ) : (
- <KeywordsTab
- projectId={projectId}
- target={state.overview.displayTarget}
- hostname={state.overview.domain}
- scope={state.overview.scope}
- routeState={routeState}
- tabs={tabs}
- canSaveKeywords={state.canSaveKeywords}
- setSearchParams={state.setSearchParams}
- onSortClick={state.handleSortColumnClick}
- onPageChange={state.goToPage}
- onPageSizeChange={state.setPageSize}
- />
- )}
+ <Card className="gap-0 py-0">
+ <div className="flex flex-wrap items-center gap-2 px-4 pt-4 pb-3">
+ <h2 className="text-lg font-semibold break-all">
+ {state.overview.displayTarget}
+ </h2>
+ <Badge variant="outline">
+ {RESEARCH_SCOPE_LABELS[state.overview.scope]}
+ </Badge>
+ </div>
+ <div className="px-4 pb-4">
+ <div className="grid grid-cols-1 gap-3 rounded-lg border border-border p-3 md:grid-cols-2">
+ <StatTile
+ label="Estimated Organic Traffic"
+ value={formatMetric(
+ state.overview.organicTraffic,
+ state.overview.hasData,
+ )}
+ hint={overviewMetricsHint}
+ />
+ <StatTile
+ label="Organic Keywords"
+ value={formatMetric(
+ state.overview.organicKeywords,
+ state.overview.hasData,
+ )}
+ hint={overviewMetricsHint}
+ />
+ </div>
+ </div>
+
+ <div className="px-4 pb-4">
+ {routeState.tab === "pages" ? (
+ <PagesTab
+ projectId={projectId}
+ target={state.overview.displayTarget}
+ hostname={state.overview.domain}
+ scope={state.overview.scope}
+ routeState={routeState}
+ tabs={tabs}
+ setSearchParams={state.setSearchParams}
+ onSortClick={state.handleSortColumnClick}
+ onPageChange={state.goToPage}
+ onPageSizeChange={state.setPageSize}
+ />
+ ) : (
+ <KeywordsTab
+ projectId={projectId}
+ target={state.overview.displayTarget}
+ hostname={state.overview.domain}
+ scope={state.overview.scope}
+ routeState={routeState}
+ tabs={tabs}
+ canSaveKeywords={state.canSaveKeywords}
+ setSearchParams={state.setSearchParams}
+ onSortClick={state.handleSortColumnClick}
+ onPageChange={state.goToPage}
+ onPageSizeChange={state.setPageSize}
+ />
+ )}
+ </div>
+ </Card>
</>
)}
</div>
diff --git a/src/client/features/domain/components/DomainOverviewLoadingState.tsx b/src/client/features/domain/components/DomainOverviewLoadingState.tsx
index 69734b31..e61beb81 100644
--- a/src/client/features/domain/components/DomainOverviewLoadingState.tsx
+++ b/src/client/features/domain/components/DomainOverviewLoadingState.tsx
@@ -1,26 +1,29 @@
-import {
- SkeletonStatGrid,
- SkeletonTableRows,
-} from "@/client/components/SkeletonPresets";
-import { Card, CardContent } from "@/client/components/ui/card";
+import { SkeletonTableRows } from "@/client/components/SkeletonPresets";
+import { Card } from "@/client/components/ui/card";
import { Skeleton } from "@/client/components/ui/skeleton";
export function DomainOverviewLoadingState() {
return (
- <div className="space-y-4" aria-busy>
- <SkeletonStatGrid
- count={2}
- className="grid-cols-1 md:grid-cols-2 lg:grid-cols-2"
- />
- <Card>
- <CardContent className="space-y-4">
- <div className="flex items-center justify-between">
- <Skeleton className="h-8 w-48" />
- <Skeleton className="h-8 w-60" />
- </div>
+ <Card className="gap-0 py-0" aria-busy>
+ <div className="px-4 pt-4 pb-3">
+ <Skeleton className="h-6 w-48" />
+ </div>
+ <div className="px-4 pb-4">
+ <div className="grid grid-cols-1 gap-3 rounded-lg border border-border p-3 md:grid-cols-2">
+ {Array.from({ length: 2 }, (_, index) => (
+ <div key={index} className="space-y-2">
+ <Skeleton className="h-3 w-32" />
+ <Skeleton className="h-7 w-24" />
+ </div>
+ ))}
+ </div>
+ </div>
+ <div className="px-4 pb-4">
+ <div className="space-y-4 rounded-xl border border-border p-4">
+ <Skeleton className="h-6 w-48" />
<SkeletonTableRows />
- </CardContent>
- </Card>
- </div>
+ </div>
+ </div>
+ </Card>
);
}
diff --git a/src/client/features/keywords/page/KeywordResearchPage.tsx b/src/client/features/keywords/page/KeywordResearchPage.tsx
index 3fb5fbeb..20e70e54 100644
--- a/src/client/features/keywords/page/KeywordResearchPage.tsx
+++ b/src/client/features/keywords/page/KeywordResearchPage.tsx
@@ -2,8 +2,7 @@ import { Link } from "@tanstack/react-router";
import { useCallback, useMemo } from "react";
import { ErrorState } from "@/client/components/ErrorState";
import { FormDialog } from "@/client/components/FormDialog";
-import { PageHeader } from "@/client/components/PageHeader";
-import { RecentSearchesBackLink } from "@/client/components/RecentSearches";
+import { BackButton, PageHeader } from "@/client/components/PageHeader";
import { Button } from "@/client/components/ui/button";
import { getErrorCode } from "@/client/lib/error-messages";
import { BILLING_ROUTE } from "@/shared/billing";
@@ -203,30 +202,28 @@ export function KeywordResearchPage(input: Props) {
<PageHeader
title="Keyword Research"
description="Discover keyword ideas, search demand, and ranking opportunities."
+ backLink={
+ controller.hasSearched ? (
+ <BackButton
+ data-testid="keyword-research-recent-searches"
+ onClick={showRecentSearches}
+ >
+ Recent searches
+ </BackButton>
+ ) : undefined
+ }
/>
<KeywordResearchSearchBar controller={controller} />
{controller.hasSearched ? (
- <div className="flex flex-col gap-2">
- <RecentSearchesBackLink
- render={(props) => (
- <button
- type="button"
- data-testid="keyword-research-recent-searches"
- onClick={showRecentSearches}
- {...props}
- />
- )}
- />
- <SearchTabStrip
- projectId={projectId}
- tabs={searchTabs.tabs}
- activeTabId={searchTabs.activeTabId}
- onSelect={searchTabs.selectTab}
- onClose={searchTabs.closeTab}
- onViewed={searchTabs.markTabViewed}
- />
- </div>
+ <SearchTabStrip
+ projectId={projectId}
+ tabs={searchTabs.tabs}
+ activeTabId={searchTabs.activeTabId}
+ onSelect={searchTabs.selectTab}
+ onClose={searchTabs.closeTab}
+ onViewed={searchTabs.markTabViewed}
+ />
) : null}
<KeywordResearchContent
controller={controller}
diff --git a/src/client/features/lighthouse/issues/LighthouseIssuesParts.tsx b/src/client/features/lighthouse/issues/LighthouseIssuesParts.tsx
index ffca4d5a..297443ff 100644
--- a/src/client/features/lighthouse/issues/LighthouseIssuesParts.tsx
+++ b/src/client/features/lighthouse/issues/LighthouseIssuesParts.tsx
@@ -1,7 +1,6 @@
-import { ChevronLeft } from "lucide-react";
+import { BackButton } from "@/client/components/PageHeader";
import { ExportMenu } from "@/client/components/ExportMenu";
import { Spinner } from "@/client/components/Spinner";
-import { Button } from "@/client/components/ui/button";
import { Card, CardContent } from "@/client/components/ui/card";
import {
Table,
@@ -44,10 +43,7 @@ export function LighthouseIssuesHeader({
return (
<>
<div className="flex items-center justify-between gap-3">
- <Button variant="ghost" size="sm" className="-ml-2.5" onClick={onBack}>
- <ChevronLeft data-icon="inline-start" />
- Back to Site Audit
- </Button>
+ <BackButton onClick={onBack}>Site Audit</BackButton>
<span className="text-xs text-muted-foreground">
{scannedAt
? `Scanned ${new Date(scannedAt).toLocaleString()}`
diff --git a/src/client/features/projects/ProjectPageHeader.tsx b/src/client/features/projects/ProjectPageHeader.tsx
index cb4e00af..413223e4 100644
--- a/src/client/features/projects/ProjectPageHeader.tsx
+++ b/src/client/features/projects/ProjectPageHeader.tsx
@@ -15,9 +15,12 @@ export function ProjectPageHeader({
const project = projectsQuery.data?.find((entry) => entry.id === projectId);
return (
- <div className="space-y-4">
- {showBackLink ? <BackLink to="/projects">Projects</BackLink> : null}
- <PageHeader title={title} description={project?.name ?? " "} />
- </div>
+ <PageHeader
+ title={title}
+ description={project?.name ?? " "}
+ backLink={
+ showBackLink ? <BackLink to="/projects">Projects</BackLink> : undefined
+ }
+ />
);
}
diff --git a/src/client/features/rank-tracking/RankTrackingDomainDetail.tsx b/src/client/features/rank-tracking/RankTrackingDomainDetail.tsx
index 7b629e98..916409c3 100644
--- a/src/client/features/rank-tracking/RankTrackingDomainDetail.tsx
+++ b/src/client/features/rank-tracking/RankTrackingDomainDetail.tsx
@@ -11,7 +11,6 @@ import {
estimateRankCheckCost,
} from "@/serverFunctions/rank-tracking";
import { AlertTriangle } from "lucide-react";
-import { BackLink } from "@/client/components/PageHeader";
import { QueryState } from "@/client/components/QueryState";
import { PageLoading } from "@/client/components/Spinner";
import { Alert, AlertDescription } from "@/client/components/ui/alert";
@@ -235,10 +234,6 @@ export function RankTrackingDomainDetail({
return (
<div className="space-y-3">
- <BackLink to="/p/$projectId/rank-tracking" params={{ projectId }}>
- Back to domains
- </BackLink>
-
{config.lastSkipReason === "insufficient_credits" && (
<Alert variant="warning">
<AlertTriangle />
diff --git a/src/routes/_app/p/$projectId/rank-tracking.tsx b/src/routes/_app/p/$projectId/rank-tracking.tsx
index 34eb1821..9c45008b 100644
--- a/src/routes/_app/p/$projectId/rank-tracking.tsx
+++ b/src/routes/_app/p/$projectId/rank-tracking.tsx
@@ -1,17 +1,27 @@
-import { createFileRoute, Outlet } from "@tanstack/react-router";
-import { PageHeader } from "@/client/components/PageHeader";
+import { createFileRoute, Outlet, useParams } from "@tanstack/react-router";
+import { BackLink, PageHeader } from "@/client/components/PageHeader";
export const Route = createFileRoute("/_app/p/$projectId/rank-tracking")({
component: RankTrackingLayout,
});
function RankTrackingLayout() {
+ // Only the domain detail route has a config id, and only it links back.
+ const { projectId, configId } = useParams({ strict: false });
+
return (
<div className="px-4 py-4 pb-24 overflow-auto md:px-6 md:py-6 md:pb-8">
<div className="mx-auto max-w-7xl space-y-4">
<PageHeader
title="Rank Tracking"
description="Track keyword positions across domains"
+ backLink={
+ projectId && configId ? (
+ <BackLink to="/p/$projectId/rank-tracking" params={{ projectId }}>
+ Tracked domains
+ </BackLink>
+ ) : undefined
+ }
/>
<Outlet />
diff --git a/src/routes/_app/p/$projectId/reports/$reportId.tsx b/src/routes/_app/p/$projectId/reports/$reportId.tsx
index 0ee1187b..a39f5064 100644
--- a/src/routes/_app/p/$projectId/reports/$reportId.tsx
+++ b/src/routes/_app/p/$projectId/reports/$reportId.tsx
@@ -161,90 +161,90 @@ function ReportDetailPage() {
// keep the content as wide as the other pages (max-w-7xl).
return (
<div className="mx-auto flex h-full min-h-0 max-w-[calc(var(--container-7xl)+2rem)] flex-col gap-3 px-4 py-4 md:max-w-[calc(var(--container-7xl)+3rem)] md:px-6 md:py-6">
- {reportQuery.isError ? <QueryError {...loadError} /> : null}
- <div className="space-y-3">
- <BackLink to="/p/$projectId/reports" params={{ projectId }}>
- Reports
- </BackLink>
- <PageHeader
- title={report.title}
- description={
- <dl className="flex flex-wrap items-baseline gap-x-6 gap-y-1 text-foreground">
- <div className="flex items-baseline gap-1.5">
- <dt className="text-muted-foreground">Created by</dt>
- <dd>{formatCreatedBy(report)}</dd>
- </div>
- <div className="flex items-baseline gap-1.5">
- <dt className="text-muted-foreground">Type</dt>
- {/* As in the list's Type column: the template name when the
+ <PageHeader
+ backLink={
+ <BackLink to="/p/$projectId/reports" params={{ projectId }}>
+ Reports
+ </BackLink>
+ }
+ title={report.title}
+ description={
+ <dl className="flex flex-wrap items-baseline gap-x-6 gap-y-1 text-foreground">
+ <div className="flex items-baseline gap-1.5">
+ <dt className="text-muted-foreground">Created by</dt>
+ <dd>{formatCreatedBy(report)}</dd>
+ </div>
+ <div className="flex items-baseline gap-1.5">
+ <dt className="text-muted-foreground">Type</dt>
+ {/* As in the list's Type column: the template name when the
report followed one, else the skill, else an em dash. */}
- <dd>{report.templateName ?? report.skill ?? "—"}</dd>
- </div>
- <div className="flex items-baseline gap-1.5">
- <dt className="text-muted-foreground">Updated</dt>
- <dd title={new Date(report.updatedAt).toLocaleString()}>
- {formatRelativeTime(report.updatedAt)}
- </dd>
- </div>
- </dl>
- }
- actions={
- <>
- {/* Share links are hosted-only (see shareAccess.ts), so a
+ <dd>{report.templateName ?? report.skill ?? "—"}</dd>
+ </div>
+ <div className="flex items-baseline gap-1.5">
+ <dt className="text-muted-foreground">Updated</dt>
+ <dd title={new Date(report.updatedAt).toLocaleString()}>
+ {formatRelativeTime(report.updatedAt)}
+ </dd>
+ </div>
+ </dl>
+ }
+ actions={
+ <>
+ {/* Share links are hosted-only (see shareAccess.ts), so a
self-hosted deployment keeps Export as its primary action
rather than offering a button the server would refuse. The
icon carries the state: a globe once a public link is live, a
lock while only members can open it. */}
- {hosted ? (
- <Button onClick={() => setShowShare(true)}>
- {report.shareToken ? (
- <Globe data-icon="inline-start" />
- ) : (
- <Lock data-icon="inline-start" />
- )}
- Share
- </Button>
- ) : (
- <Button onClick={exportPdf}>
- <FileDown data-icon="inline-start" />
- Export
- </Button>
- )}
- <DropdownMenu>
- <DropdownMenuTrigger
- render={
- <Button
- variant="ghost"
- size="icon"
- aria-label="Report actions"
- />
- }
+ {hosted ? (
+ <Button onClick={() => setShowShare(true)}>
+ {report.shareToken ? (
+ <Globe data-icon="inline-start" />
+ ) : (
+ <Lock data-icon="inline-start" />
+ )}
+ Share
+ </Button>
+ ) : (
+ <Button onClick={exportPdf}>
+ <FileDown data-icon="inline-start" />
+ Export
+ </Button>
+ )}
+ <DropdownMenu>
+ <DropdownMenuTrigger
+ render={
+ <Button
+ variant="ghost"
+ size="icon"
+ aria-label="Report actions"
+ />
+ }
+ >
+ <MoreHorizontal />
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="end" className="w-52">
+ {hosted ? (
+ <>
+ <DropdownMenuItem onClick={exportPdf}>
+ <FileDown />
+ Export
+ </DropdownMenuItem>
+ <DropdownMenuSeparator />
+ </>
+ ) : null}
+ <DropdownMenuItem
+ variant="destructive"
+ onClick={() => setShowDelete(true)}
>
- <MoreHorizontal />
- </DropdownMenuTrigger>
- <DropdownMenuContent align="end" className="w-52">
- {hosted ? (
- <>
- <DropdownMenuItem onClick={exportPdf}>
- <FileDown />
- Export
- </DropdownMenuItem>
- <DropdownMenuSeparator />
- </>
- ) : null}
- <DropdownMenuItem
- variant="destructive"
- onClick={() => setShowDelete(true)}
- >
- <Trash2 />
- Delete
- </DropdownMenuItem>
- </DropdownMenuContent>
- </DropdownMenu>
- </>
- }
- />
- </div>
+ <Trash2 />
+ Delete
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </>
+ }
+ />
+ {reportQuery.isError ? <QueryError {...loadError} /> : null}
<div className="relative min-h-0 flex-1">
{/* View controls float over the top-right corner of the report frame.
diff --git a/src/routes/_app/p/$projectId/reports/templates.tsx b/src/routes/_app/p/$projectId/reports/templates.tsx
index bc2a0f05..62f69505 100644
--- a/src/routes/_app/p/$projectId/reports/templates.tsx
+++ b/src/routes/_app/p/$projectId/reports/templates.tsx
@@ -66,11 +66,12 @@ function ReportTemplatesPage() {
return (
<div className="overflow-auto px-4 py-4 pb-24 md:px-6 md:py-6 md:pb-8">
<div className="mx-auto max-w-7xl space-y-4">
- <BackLink to="/p/$projectId/reports" params={{ projectId }}>
- Reports
- </BackLink>
-
<PageHeader
+ backLink={
+ <BackLink to="/p/$projectId/reports" params={{ projectId }}>
+ Reports
+ </BackLink>
+ }
title="Report templates"
description="Reusable briefs your agents follow when they write a report: who it is for, which sections it has, and how it should sound."
actions={