From 174c730f1f928107e99a46e57d984b119f80ecb4 Mon Sep 17 00:00:00 2001 From: Richard Poelderl Date: Fri, 2 Jun 2023 20:28:03 +0200 Subject: [PATCH] chore: add canonical to the document via `PageWrapper` (#8639) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * add canonical to the document via `PageWrapper` * use WEBSITE_URL constant to create the canonical url value --------- Co-authored-by: Keith Williams Co-authored-by: Efraín Rochín Co-authored-by: Peer Richelsen --- apps/web/components/PageWrapper.tsx | 19 ++++++++++++++++++- packages/lib/browser/browser.utils.ts | 2 ++ packages/lib/next-seo.config.ts | 11 +++++++++++ packages/ui/components/head-seo/HeadSeo.tsx | 13 +++++++------ 4 files changed, 38 insertions(+), 7 deletions(-) diff --git a/apps/web/components/PageWrapper.tsx b/apps/web/components/PageWrapper.tsx index cbd9f19ece..ad7ad649de 100644 --- a/apps/web/components/PageWrapper.tsx +++ b/apps/web/components/PageWrapper.tsx @@ -5,6 +5,8 @@ import Script from "next/script"; import "@calcom/embed-core/src/embed-iframe"; import LicenseRequired from "@calcom/features/ee/common/components/LicenseRequired"; +import { WEBAPP_URL } from "@calcom/lib/constants"; +import { buildCanonical } from "@calcom/lib/next-seo.config"; import type { AppProps } from "@lib/app-providers"; import AppProviders from "@lib/app-providers"; @@ -49,9 +51,24 @@ function PageWrapper(props: AppProps) { }; // Use the layout defined at the page level, if available const getLayout = Component.getLayout ?? ((page) => page); + + // Canonical: Check if the URL is from cal.com so that we set the canonical conditionally + const isCalcom = + WEBAPP_URL && + (new URL(WEBAPP_URL).hostname.endsWith("cal.com") || new URL(WEBAPP_URL).hostname.endsWith("cal.dev")); + const path = router.asPath; + return ( - +