feat(web): open every external link in a new tab, derived from the URL (MITHOME-124)
General rule: links to another host open in a new tab with rel="noopener noreferrer"; internal paths, mailto: and tel: stay in the same tab. Behaviour was inconsistent before — the home Webmail button opened in the same tab while the other webmail links did not, and the CTA and header relied on a manual "external" switch. src/lib/external-link.ts decides from the URL (externalLinkProps for JSX, openExternalLinksInNewTab for CMS-provided HTML in About paragraphs, legal pages and the GDPR label). All link sites use it; the manual "external" CTA checkbox and NavigationItem flag are removed so the rule cannot be bypassed. Rule documented in architecture.md and CLAUDE.md; staging smoke SMOKE-07 checks every external homepage link. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
183b304687
commit
ca4d447d73
@@ -1,6 +1,7 @@
|
||||
import Image from 'next/image'
|
||||
import { localePath, type Locale } from '@/lib/i18n'
|
||||
import type { getHomeContent, PartnerView } from '@/lib/payload-content'
|
||||
import { externalLinkProps } from '@/lib/external-link'
|
||||
|
||||
type HomeViewProps = {
|
||||
content: Awaited<ReturnType<typeof getHomeContent>>
|
||||
@@ -69,8 +70,7 @@ export default function HomeView({ content: pageContent, partners, locale }: Hom
|
||||
>
|
||||
<a
|
||||
href={pageContent.hero.cta.primary.href}
|
||||
target={pageContent.hero.cta.primary.external ? '_blank' : undefined}
|
||||
rel={pageContent.hero.cta.primary.external ? 'noopener noreferrer' : undefined}
|
||||
{...externalLinkProps(pageContent.hero.cta.primary.href)}
|
||||
className="btn btn-primary text-lg px-8 py-4 group"
|
||||
>
|
||||
<svg
|
||||
@@ -86,6 +86,7 @@ export default function HomeView({ content: pageContent, partners, locale }: Hom
|
||||
{pageContent.hero.cta.secondary && (
|
||||
<a
|
||||
href={pageContent.hero.cta.secondary.href}
|
||||
{...externalLinkProps(pageContent.hero.cta.secondary.href)}
|
||||
className="btn btn-secondary text-lg px-8 py-4"
|
||||
>
|
||||
{pageContent.hero.cta.secondary.text}
|
||||
@@ -248,8 +249,7 @@ export default function HomeView({ content: pageContent, partners, locale }: Hom
|
||||
<a
|
||||
key={partner.name}
|
||||
href={partner.url}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
{...externalLinkProps(partner.url)}
|
||||
className="group flex flex-col items-center gap-3 opacity-80 hover:opacity-100 transition-opacity duration-200"
|
||||
title={partner.name}
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user