diff --git a/src/app/manufacturers/[slug]/BackLink.tsx b/src/app/manufacturers/[slug]/BackLink.tsx new file mode 100644 index 0000000..bc6e733 --- /dev/null +++ b/src/app/manufacturers/[slug]/BackLink.tsx @@ -0,0 +1,36 @@ +"use client"; + +/** + * Smart back link for the manufacturer profile page. + * + * Renders as a server-rendered linking to the directory so search + * engines and no-JS users still get a sensible href. Client-side it + * intercepts the click and calls `router.back()` — if the user arrived + * here from anywhere on the BB site (homepage Content Partners hover, + * an article body link, the directory itself) we'll return them there. + * Falls through to the directory only when there is no in-app history. + */ +import Link from "next/link"; +import { useRouter } from "next/navigation"; +import type { MouseEvent } from "react"; + +export default function BackLink() { + const router = useRouter(); + function onClick(e: MouseEvent) { + if (typeof window === "undefined") return; + // Same-origin Referer means we have somewhere to go back to. The + // browser history length > 1 check catches the case where the user + // opened the profile in a new tab — in that case we leave the default + // navigation (to /manufacturers) alone. + const sameOrigin = !!document.referrer && new URL(document.referrer).origin === window.location.origin; + if (sameOrigin && window.history.length > 1) { + e.preventDefault(); + router.back(); + } + } + return ( + + ← Back + + ); +} diff --git a/src/app/manufacturers/[slug]/page.tsx b/src/app/manufacturers/[slug]/page.tsx index e0a93a8..e9f9052 100644 --- a/src/app/manufacturers/[slug]/page.tsx +++ b/src/app/manufacturers/[slug]/page.tsx @@ -4,6 +4,7 @@ import Link from "next/link"; import Header from "@/components/Header"; import Footer from "@/components/Footer"; import { createClient } from "@/lib/supabase/server"; +import BackLink from "./BackLink"; export const revalidate = 1800; @@ -166,9 +167,7 @@ export default async function ManufacturerProfile({ />
diff --git a/src/components/CompanyMentionsHover.tsx b/src/components/CompanyMentionsHover.tsx index f08c82b..46e2f18 100644 --- a/src/components/CompanyMentionsHover.tsx +++ b/src/components/CompanyMentionsHover.tsx @@ -99,68 +99,68 @@ export default function CompanyMentionsHover() { role="dialog" aria-label={preview?.name ? `${preview.name} preview` : "Company preview"} style={{ position: "absolute", top: pos.top, left: pos.left, width: 360, zIndex: 999 }} - className="bg-white text-ink border border-ink/10 rounded-xl shadow-2xl p-4 text-sm" + className="bg-[#111827] text-[#e8e8e8] border border-[#2a3a50] rounded-xl shadow-2xl p-4 text-sm backdrop-blur-sm" onMouseEnter={() => { if (hideTimer.current) { window.clearTimeout(hideTimer.current); hideTimer.current = null; } }} onMouseLeave={() => { hideTimer.current = window.setTimeout(() => { setAnchor(null); setPreview(null); setPos(null); }, 180); }} > {loading || !preview ? ( -
Loading…
+
Loading…
) : ( <>
{preview.logoUrl ? ( /* eslint-disable-next-line @next/next/no-img-element */ - + ) : ( -
+
{(preview.name || "?").trim().charAt(0).toUpperCase()}
)}
- + {preview.name} -
+
{preview.isActiveAdvertiser && ( - Sponsor + Sponsor )} {preview.exhibitsNab && ( - 2026 NAB Show + 2026 NAB Show )} {preview.exhibitsIbc && ( - IBC 2026 + IBC 2026 )} - {preview.hq && {preview.hq}} + {preview.hq && {preview.hq}}
{preview.bio && ( -

{preview.bio}

+

{preview.bio}

)} {preview.stories.length > 0 && ( -
-
Recent coverage
+
+
Recent coverage
    {preview.stories.slice(0, 3).map((s) => (
  • - + {s.title} - {s.date && · {new Date(s.date).toISOString().slice(0, 10)}} + {s.date && · {new Date(s.date).toISOString().slice(0, 10)}}
  • ))}
)} -