Skip to content

Commit ced77d5

Browse files
committed
add canonical link
1 parent eb2d1d0 commit ced77d5

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

src/theme/Root.tsx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import React, {type ReactNode} from 'react';
2+
import Head from '@docusaurus/Head';
3+
import {useLocation} from '@docusaurus/router';
4+
5+
type RootProps = {
6+
children: ReactNode;
7+
};
8+
9+
const CANONICAL_BASE_URL = 'https://docs.nxtgrid.co';
10+
11+
export default function Root({children}: RootProps): ReactNode {
12+
const location = useLocation();
13+
const canonicalUrl = `${CANONICAL_BASE_URL}${location.pathname}${location.search}`;
14+
15+
return (
16+
<>
17+
<Head>
18+
<link rel="canonical" href={canonicalUrl} />
19+
</Head>
20+
{children}
21+
</>
22+
);
23+
}

0 commit comments

Comments
 (0)