From 446ae4e31237391a40f8fb83858649f4e25ff89c Mon Sep 17 00:00:00 2001 From: Linden <65407488+thelindat@users.noreply.github.com> Date: Fri, 16 Jun 2023 20:20:32 +1000 Subject: [PATCH] improve index page titles --- theme.config.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/theme.config.tsx b/theme.config.tsx index 0cbfdc9d..55f81822 100644 --- a/theme.config.tsx +++ b/theme.config.tsx @@ -25,11 +25,12 @@ function useHead() { function useNextSeoProps() { const { asPath } = useRouter(); const arr = asPath.replace(/[-_]/g, ' ').split('/'); - const category = arr[1].replace(/(^\w|\s\w)/g, m => m.toUpperCase()) || 'Overextended' - const title = arr[arr.length - 1] + const category = arr[1][0] !== '#' && arr[1] + const rawTitle = arr[arr.length - 1] + const title = /[a-z]/.test(rawTitle) && /[A-Z]/.test(rawTitle) ? rawTitle : '%s' return { - titleTemplate: `${/[a-z]/.test(title) && /[A-Z]/.test(title) ? title : '%s'} - ${category}`, + titleTemplate: `${title} - ${rawTitle === category ? 'Overextended' : category.replace(/(^\w|\s\w)/g, m => m.toUpperCase())}`, }; }