articles: auto-link company mentions to manufacturer directory
When an article body is rendered, scan it for any company name in bb.tracked_companies (directory_visible=true) and wrap the first mention of each company in <a class="company-mention" data-company-slug="...">Name</a> linking to /manufacturers/<slug>. Caps at 12 mentions per article so heavy press-release lists don't get visually noisy. Match rules: - Word-boundary, case-insensitive - Skips text already inside <a>, <script>, <style>, code/pre/headings - Skips any element with data-no-autolink="true" - Longest name wins on overlap (Sony Pictures beats Sony) - One link per company per article (first occurrence) Hover behavior: a new CompanyMentionsHover client component mounts once per article page, listens globally for [data-company-slug] hovers, and pops a floating card showing logo, name, 2-sentence bio, sponsor/NAB/IBC badges, HQ city, 3 recent stories, and links to the full profile + external website. Preview data fetched from new endpoint /api/public/companies/[slug]/preview with a client-side cache keyed by slug. Includes non-advertisers — any visible directory entry gets linked, which is the point. If a company is *also* a current banner advertiser on broadcastbeat, the hover card adds a green "Sponsor" badge. Styling: dotted underline that becomes solid on hover, slightly bolder weight, accent color on hover. Subtle so multi-mention paragraphs don't look like a link-soup.
This commit is contained in:
@@ -591,6 +591,25 @@ h1, h2, h3 {
|
||||
color: var(--color-accent-dark);
|
||||
}
|
||||
|
||||
/* Auto-linked company mentions (manufacturer directory cross-links).
|
||||
Subtler than a generic link so they don't visually swamp the body copy
|
||||
when several appear in one paragraph. */
|
||||
.article-body a.company-mention,
|
||||
a.company-mention {
|
||||
color: #e0e0e0;
|
||||
text-decoration: none;
|
||||
border-bottom: 1px dotted var(--color-accent);
|
||||
font-weight: 600;
|
||||
cursor: help;
|
||||
transition: color var(--transition-fast), border-color var(--transition-fast);
|
||||
}
|
||||
.article-body a.company-mention:hover,
|
||||
a.company-mention:hover {
|
||||
color: var(--color-accent);
|
||||
border-bottom-color: var(--color-accent);
|
||||
border-bottom-style: solid;
|
||||
}
|
||||
|
||||
.article-body blockquote {
|
||||
border-left: 3px solid var(--color-accent);
|
||||
padding-left: 1rem;
|
||||
|
||||
Reference in New Issue
Block a user