2023-02-16 22:39:57 +00:00
|
|
|
import type { DefaultSeoProps, NextSeoProps } from "next-seo";
|
2023-06-02 18:28:03 +00:00
|
|
|
import type { Router } from "next/router";
|
2022-08-24 20:18:42 +00:00
|
|
|
|
2022-11-30 21:52:56 +00:00
|
|
|
import { APP_NAME, SEO_IMG_DEFAULT, SEO_IMG_OGIMG } from "@calcom/lib/constants";
|
2022-08-24 20:18:42 +00:00
|
|
|
|
2023-02-16 22:39:57 +00:00
|
|
|
import type { AppImageProps, MeetingImageProps } from "./OgImages";
|
2022-10-18 17:46:22 +00:00
|
|
|
|
2022-08-24 20:18:42 +00:00
|
|
|
export type HeadSeoProps = {
|
|
|
|
title: string;
|
|
|
|
description: string;
|
|
|
|
siteName?: string;
|
|
|
|
url?: string;
|
|
|
|
canonical?: string;
|
|
|
|
nextSeoProps?: NextSeoProps;
|
2022-10-18 17:46:22 +00:00
|
|
|
app?: AppImageProps;
|
|
|
|
meeting?: MeetingImageProps;
|
2022-08-24 20:18:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
const seoImages = {
|
|
|
|
default: SEO_IMG_DEFAULT,
|
|
|
|
ogImage: SEO_IMG_OGIMG,
|
|
|
|
};
|
|
|
|
|
|
|
|
export const getSeoImage = (key: keyof typeof seoImages): string => {
|
|
|
|
return seoImages[key];
|
|
|
|
};
|
|
|
|
|
|
|
|
export const seoConfig: {
|
|
|
|
headSeo: Required<Pick<HeadSeoProps, "siteName">>;
|
|
|
|
defaultNextSeo: DefaultSeoProps;
|
|
|
|
} = {
|
|
|
|
headSeo: {
|
2022-11-30 21:52:56 +00:00
|
|
|
siteName: APP_NAME,
|
2022-08-24 20:18:42 +00:00
|
|
|
},
|
|
|
|
defaultNextSeo: {
|
|
|
|
twitter: {
|
|
|
|
handle: "@calcom",
|
|
|
|
site: "@calcom",
|
|
|
|
cardType: "summary_large_image",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
} as const;
|
2023-06-02 18:28:03 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
2023-10-10 21:50:15 +00:00
|
|
|
export const buildCanonical = ({
|
|
|
|
origin,
|
|
|
|
path,
|
|
|
|
}: {
|
|
|
|
origin: Location["origin"];
|
|
|
|
path: Router["asPath"] | null;
|
|
|
|
}) => {
|
2023-06-02 18:28:03 +00:00
|
|
|
return `${origin}${path === "/" ? "" : path}`.split("?")[0];
|
|
|
|
};
|