From d538c56d2600da6d32583f5c0b52c30be4b4ff80 Mon Sep 17 00:00:00 2001 From: Ardeman Date: Fri, 14 Mar 2025 17:48:09 +0800 Subject: [PATCH] feat: improve page title handling by limiting path segments for meta title lookup --- app/root.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/root.tsx b/app/root.tsx index 9c4da57..57f89e2 100644 --- a/app/root.tsx +++ b/app/root.tsx @@ -23,9 +23,9 @@ export const links: Route.LinksFunction = () => [ export const meta = ({ location }: Route.MetaArgs) => { const { pathname } = location - const pageTitle = META_TITLE_CONFIG.find( - (meta) => meta.path === pathname, - )?.title + const segments = pathname.split('/') + const path = segments.length > 4 ? segments.slice(0, 4).join('/') : pathname + const pageTitle = META_TITLE_CONFIG.find((meta) => meta.path === path)?.title const metaTitle = APP.title const title = `${pageTitle ? `${pageTitle} - ` : ''}${metaTitle}`