use page category for title

This commit is contained in:
Linden committed 2023-06-16 18:07:40 +10:00
1 parent 3bc548fce4
commit b5443f9b52
1 file changed
+4 -3
+4 -3
View File
@@ -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}`,
};
}