chore: add canonical to the document via PageWrapper (#8639)
* add canonical to the document via `PageWrapper` * use WEBSITE_URL constant to create the canonical url value --------- Co-authored-by: Keith Williams <[email protected]> Co-authored-by: Efraín Rochín <[email protected]> Co-authored-by: Peer Richelsen <[email protected]>
This commit is contained in:
4 files changed
+38
-7
No files matched your search
@@ -4,6 +4,7 @@ type BrowserInfo = {
|
||||
referrer: string;
|
||||
title: string;
|
||||
query: string;
|
||||
origin: string;
|
||||
};
|
||||
|
||||
export const getBrowserInfo = (): Partial<BrowserInfo> => {
|
||||
@@ -16,5 +17,6 @@ export const getBrowserInfo = (): Partial<BrowserInfo> => {
|
||||
referrer: window.document?.referrer ?? undefined,
|
||||
title: window.document.title ?? undefined,
|
||||
query: window.document.location?.search,
|
||||
origin: window.document.location?.origin,
|
||||
};
|
||||
};
|
||||
@@ -1,4 +1,5 @@
|
||||
import type { DefaultSeoProps, NextSeoProps } from "next-seo";
|
||||
import type { Router } from "next/router";
|
||||
|
||||
import { APP_NAME, SEO_IMG_DEFAULT, SEO_IMG_OGIMG } from "@calcom/lib/constants";
|
||||
|
||||
@@ -39,3 +40,13 @@ export const seoConfig: {
|
||||
},
|
||||
},
|
||||
} as const;
|
||||
|
||||
/**
|
||||
* This function builds a canonical URL from a given host and path omitting the query params. Note: on homepage it omits the trailing slash
|
||||
* @param origin The protocol + host, e.g. `https://cal.com` or `https://cal.dev`
|
||||
* @param path NextJS' useRouter().asPath
|
||||
* @returns
|
||||
*/
|
||||
export const buildCanonical = ({ origin, path }: { origin: Location["origin"]; path: Router["asPath"] }) => {
|
||||
return `${origin}${path === "/" ? "" : path}`.split("?")[0];
|
||||
};
|
||||
Reference in new issue
Block a user