From 773e91d4906b9c1539469d99aa47bc77717de360 Mon Sep 17 00:00:00 2001 From: Usman Baig Date: Fri, 27 Mar 2026 17:44:40 +0100 Subject: [PATCH] feat: remap PageSpeed audit links to ciphera.net/learn articles --- app/sites/[id]/pagespeed/page.tsx | 3 ++- lib/learn-links.ts | 30 ++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 lib/learn-links.ts diff --git a/app/sites/[id]/pagespeed/page.tsx b/app/sites/[id]/pagespeed/page.tsx index 8980d2e..c0eade6 100644 --- a/app/sites/[id]/pagespeed/page.tsx +++ b/app/sites/[id]/pagespeed/page.tsx @@ -8,6 +8,7 @@ import { updatePageSpeedConfig, triggerPageSpeedCheck, getPageSpeedLatest, getPa import { toast, Button } from '@ciphera-net/ui' import { motion } from 'framer-motion' import ScoreGauge from '@/components/pagespeed/ScoreGauge' +import { remapLearnUrl } from '@/lib/learn-links' import { AreaChart as VisxAreaChart, Area as VisxArea, Grid as VisxGrid, XAxis as VisxXAxis, YAxis as VisxYAxis, ChartTooltip as VisxChartTooltip } from '@/components/ui/area-chart' import { useMinimumLoading, useSkeletonFade } from '@/components/skeletons' @@ -788,7 +789,7 @@ function AuditDescription({ text }: { text: string }) { return ( = { + // Performance Metrics + 'developer.chrome.com/docs/lighthouse/performance/first-contentful-paint': 'https://ciphera.net/learn/first-contentful-paint', + 'developer.chrome.com/docs/lighthouse/performance/lighthouse-largest-contentful-paint': 'https://ciphera.net/learn/largest-contentful-paint', + 'developer.chrome.com/docs/lighthouse/performance/lighthouse-total-blocking-time': 'https://ciphera.net/learn/total-blocking-time', + 'web.dev/articles/cls': 'https://ciphera.net/learn/cumulative-layout-shift', + 'developer.chrome.com/docs/lighthouse/performance/speed-index': 'https://ciphera.net/learn/speed-index', + 'web.dev/articles/inp': 'https://ciphera.net/learn/interaction-to-next-paint', + 'developer.chrome.com/docs/lighthouse/performance/interactive': 'https://ciphera.net/learn/time-to-interactive', + 'developer.chrome.com/docs/lighthouse/performance/lighthouse-max-potential-fid': 'https://ciphera.net/learn/max-potential-first-input-delay', +} + +function normalizeUrl(url: string): string { + try { + const u = new URL(url) + return (u.host + u.pathname).replace(/\/+$/, '') + } catch { + return url + } +} + +export function remapLearnUrl(url: string): string { + const normalized = normalizeUrl(url) + return LEARN_URL_MAP[normalized] || url +}