Skip to content

Commit fbe96eb

Browse files
Resolve incorrect meta tag rendering for nested
routes (e.g., `/blog/my-first-post`) by using `firstSegment` logic in the `Meta` component. Metadata now reflects the correct parent route instead of defaulting to `/`.
1 parent f45b2c3 commit fbe96eb

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

components/layout/Meta.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ import Script from 'next/script';
55

66
export default function Meta() {
77
const currentPath = usePathname();
8-
const meta = currentPath in pageMeta ? pageMeta[currentPath] : pageMeta['/'];
8+
const firstSegment = '/' + currentPath.split('/')[1];
9+
const meta =
10+
firstSegment in pageMeta ? pageMeta[firstSegment] : pageMeta['/'];
911
return (
1012
<>
1113
<Head>

0 commit comments

Comments
 (0)