Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(web): set canonical as https://cal.com in the <HeadSeo/> #6693

Merged
merged 6 commits into from Jan 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 6 additions & 2 deletions packages/ui/components/head-seo/HeadSeo.tsx
@@ -1,5 +1,6 @@
import merge from "lodash/merge";
import { NextSeo, NextSeoProps } from "next-seo";
import { useRouter } from "next/router";

import {
AppImageProps,
Expand All @@ -10,6 +11,7 @@ import {
} from "@calcom/lib/OgImages";
import { getBrowserInfo } from "@calcom/lib/browser/browser.utils";
import { APP_NAME } from "@calcom/lib/constants";
import isCalcom from "@calcom/lib/isCalcom";
import { seoConfig, getSeoImage } from "@calcom/lib/next-seo.config";
import { truncateOnWord } from "@calcom/lib/text";

Expand Down Expand Up @@ -72,13 +74,15 @@ const buildSeoMeta = (pageProps: {
};

export const HeadSeo = (props: HeadSeoProps): JSX.Element => {
const defaultUrl = getBrowserInfo()?.url;
// build the canonical url to ensure it's always cal.com (not app.cal.com)
const router = useRouter();
const calcomUrl = (`https://cal.com` + (router.asPath === "/" ? "" : router.asPath)).split("?")[0]; // cut off search params
const defaultUrl = isCalcom ? calcomUrl : getBrowserInfo()?.url;

const { title, description, siteName, canonical = defaultUrl, nextSeoProps = {}, app, meeting } = props;

const image = getSeoImage("ogImage") + constructGenericImage({ title, description });
const truncatedDescription = truncateOnWord(description, 158);

const pageTitle = title + " | " + APP_NAME;
let seoObject = buildSeoMeta({
title: pageTitle,
Expand Down