From b5443f9b521671564b27bf3493bf0769f9dda9c6 Mon Sep 17 00:00:00 2001 From: Linden <65407488+thelindat@users.noreply.github.com> Date: Fri, 16 Jun 2023 18:07:40 +1000 Subject: [PATCH] use page category for title --- theme.config.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/theme.config.tsx b/theme.config.tsx index b05c2d66..0cbfdc9d 100644 --- a/theme.config.tsx +++ b/theme.config.tsx @@ -24,11 +24,12 @@ function useHead() { function useNextSeoProps() { const { asPath } = useRouter(); - const arr = asPath.split('/'); - const title = arr[arr.length - 1].replace(/[-_]/g, ' '); + 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] return { - titleTemplate: `${/[a-z]/.test(title) && /[A-Z]/.test(title) ? title : '%s'} - Overextended`, + titleTemplate: `${/[a-z]/.test(title) && /[A-Z]/.test(title) ? title : '%s'} - ${category}`, }; }