From 18351b024c19c9ebc663549e9b2a6fc0802dca61 Mon Sep 17 00:00:00 2001 From: Benny Joo Date: Tue, 31 Oct 2023 20:05:33 +0000 Subject: [PATCH 1/4] create a util for generateMetaData --- apps/web/app/_utils.tsx | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 apps/web/app/_utils.tsx diff --git a/apps/web/app/_utils.tsx b/apps/web/app/_utils.tsx new file mode 100644 index 00000000000000..43e0af6c30b0cf --- /dev/null +++ b/apps/web/app/_utils.tsx @@ -0,0 +1,41 @@ +import { headers } from "next/headers"; + +import { constructGenericImage } from "@calcom/lib/OgImages"; +import { IS_CALCOM, WEBAPP_URL, APP_NAME, SEO_IMG_OGIMG } from "@calcom/lib/constants"; +import { getFixedT } from "@calcom/lib/server/getFixedT"; + +import { preparePageMetadata } from "@lib/metadata"; + +export const _generateMetadata = async ( + titleKey: string, + descriptionKey: string, + usePlainTitleKey?: boolean, + usePlainDescriptionKey?: boolean +) => { + const h = headers(); + const canonical = h.get("x-pathname") ?? ""; + const locale = h.get("x-locale") ?? "en"; + + const t = await getFixedT(locale, "common"); + + const title = usePlainTitleKey ? titleKey : t(titleKey); + const description = usePlainDescriptionKey ? descriptionKey : t(descriptionKey); + + const metadataBase = new URL(IS_CALCOM ? "https://cal.com" : WEBAPP_URL); + + const image = + SEO_IMG_OGIMG + + constructGenericImage({ + title, + description, + }); + + return preparePageMetadata({ + title, + canonical, + image, + description, + siteName: APP_NAME, + metadataBase, + }); +}; From 0448c8b44de5b4ae8aeda3ebef8b8f20b48097f3 Mon Sep 17 00:00:00 2001 From: Benny Joo Date: Tue, 31 Oct 2023 20:05:43 +0000 Subject: [PATCH 2/4] remove duplicates --- .../app/future/(layout)/availability/page.tsx | 37 +----------------- .../app/future/(layout)/event-types/page.tsx | 38 ++----------------- .../web/app/future/(layout)/insights/page.tsx | 37 +----------------- .../future/(layout)/settings/billing/page.tsx | 37 +----------------- .../settings/developer/webhooks/page.tsx | 37 +----------------- .../settings/my-account/appearance/page.tsx | 37 +----------------- .../settings/my-account/calendars/page.tsx | 37 +----------------- .../settings/my-account/conferencing/page.tsx | 38 ++----------------- .../settings/my-account/general/page.tsx | 37 +----------------- .../settings/my-account/profile/page.tsx | 37 +----------------- .../settings/security/impersonation/page.tsx | 38 ++----------------- .../settings/security/password/page.tsx | 37 +----------------- .../security/two-factor-auth/page.tsx | 38 ++----------------- .../app/future/(layout)/workflows/page.tsx | 37 ++---------------- .../web/app/future/(no-layout)/video/page.tsx | 38 ++----------------- 15 files changed, 36 insertions(+), 524 deletions(-) diff --git a/apps/web/app/future/(layout)/availability/page.tsx b/apps/web/app/future/(layout)/availability/page.tsx index 52dae8e1921508..17a8a3013fb546 100644 --- a/apps/web/app/future/(layout)/availability/page.tsx +++ b/apps/web/app/future/(layout)/availability/page.tsx @@ -1,39 +1,6 @@ import AvailabilityPage from "@pages/availability"; -import { headers } from "next/headers"; +import { _generateMetadata } from "app/_utils"; -import { constructGenericImage } from "@calcom/lib/OgImages"; -import { IS_CALCOM, WEBAPP_URL, APP_NAME, SEO_IMG_OGIMG } from "@calcom/lib/constants"; -import { getFixedT } from "@calcom/lib/server/getFixedT"; - -import { preparePageMetadata } from "@lib/metadata"; - -export const generateMetadata = async () => { - const h = headers(); - const canonical = h.get("x-pathname") ?? ""; - const locale = h.get("x-locale") ?? "en"; - - const t = await getFixedT(locale, "common"); - - const title = t("availability"); - const description = t("configure_availability"); - - const metadataBase = new URL(IS_CALCOM ? "https://cal.com" : WEBAPP_URL); - - const image = - SEO_IMG_OGIMG + - constructGenericImage({ - title, - description, - }); - - return preparePageMetadata({ - title, - canonical, - image, - description, - siteName: APP_NAME, - metadataBase, - }); -}; +export const generateMetadata = async () => await _generateMetadata("availability", "configure_availability"); export default AvailabilityPage; diff --git a/apps/web/app/future/(layout)/event-types/page.tsx b/apps/web/app/future/(layout)/event-types/page.tsx index ad666cd7109840..0d7ed87d3a919d 100644 --- a/apps/web/app/future/(layout)/event-types/page.tsx +++ b/apps/web/app/future/(layout)/event-types/page.tsx @@ -1,39 +1,7 @@ import EventTypes from "@pages/event-types"; -import { headers } from "next/headers"; +import { _generateMetadata } from "app/_utils"; -import { constructGenericImage } from "@calcom/lib/OgImages"; -import { IS_CALCOM, WEBAPP_URL, APP_NAME, SEO_IMG_OGIMG } from "@calcom/lib/constants"; -import { getFixedT } from "@calcom/lib/server/getFixedT"; - -import { preparePageMetadata } from "@lib/metadata"; - -export const generateMetadata = async () => { - const h = headers(); - const canonical = h.get("x-pathname") ?? ""; - const locale = h.get("x-locale") ?? "en"; - - const t = await getFixedT(locale, "common"); - - const title = t("event_types_page_title"); - const description = t("event_types_page_subtitle"); - - const metadataBase = new URL(IS_CALCOM ? "https://cal.com" : WEBAPP_URL); - - const image = - SEO_IMG_OGIMG + - constructGenericImage({ - title, - description, - }); - - return preparePageMetadata({ - title, - canonical, - image, - description, - siteName: APP_NAME, - metadataBase, - }); -}; +export const generateMetadata = async () => + await _generateMetadata("event_types_page_title", "event_types_page_subtitle"); export default EventTypes; diff --git a/apps/web/app/future/(layout)/insights/page.tsx b/apps/web/app/future/(layout)/insights/page.tsx index d1a8e8f422bad7..29190bd85c1723 100644 --- a/apps/web/app/future/(layout)/insights/page.tsx +++ b/apps/web/app/future/(layout)/insights/page.tsx @@ -1,39 +1,6 @@ import InsightsPage from "@pages/insights"; -import { headers } from "next/headers"; +import { _generateMetadata } from "app/_utils"; -import { constructGenericImage } from "@calcom/lib/OgImages"; -import { IS_CALCOM, WEBAPP_URL, APP_NAME, SEO_IMG_OGIMG } from "@calcom/lib/constants"; -import { getFixedT } from "@calcom/lib/server/getFixedT"; - -import { preparePageMetadata } from "@lib/metadata"; - -export const generateMetadata = async () => { - const h = headers(); - const canonical = h.get("x-pathname") ?? ""; - const locale = h.get("x-locale") ?? "en"; - - const t = await getFixedT(locale, "common"); - - const title = "Insights"; - const description = t("insights_subtitle"); - - const metadataBase = new URL(IS_CALCOM ? "https://cal.com" : WEBAPP_URL); - - const image = - SEO_IMG_OGIMG + - constructGenericImage({ - title, - description, - }); - - return preparePageMetadata({ - title, - canonical, - image, - description, - siteName: APP_NAME, - metadataBase, - }); -}; +export const generateMetadata = async () => await _generateMetadata("Insights", "insights_subtitle", true); export default InsightsPage; diff --git a/apps/web/app/future/(layout)/settings/billing/page.tsx b/apps/web/app/future/(layout)/settings/billing/page.tsx index d110b9ac390c0f..3e8dfad88ca788 100644 --- a/apps/web/app/future/(layout)/settings/billing/page.tsx +++ b/apps/web/app/future/(layout)/settings/billing/page.tsx @@ -1,39 +1,6 @@ import BillingPage from "@pages/settings/billing"; -import { headers } from "next/headers"; +import { _generateMetadata } from "app/_utils"; -import { constructGenericImage } from "@calcom/lib/OgImages"; -import { IS_CALCOM, WEBAPP_URL, APP_NAME, SEO_IMG_OGIMG } from "@calcom/lib/constants"; -import { getFixedT } from "@calcom/lib/server/getFixedT"; - -import { preparePageMetadata } from "@lib/metadata"; - -export const generateMetadata = async () => { - const h = headers(); - const canonical = h.get("x-pathname") ?? ""; - const locale = h.get("x-locale") ?? "en"; - - const t = await getFixedT(locale, "common"); - - const title = t("billing"); - const description = t("manage_billing_description"); - - const metadataBase = new URL(IS_CALCOM ? "https://cal.com" : WEBAPP_URL); - - const image = - SEO_IMG_OGIMG + - constructGenericImage({ - title, - description, - }); - - return preparePageMetadata({ - title, - canonical, - image, - description, - siteName: APP_NAME, - metadataBase, - }); -}; +export const generateMetadata = async () => await _generateMetadata("billing", "manage_billing_description"); export default BillingPage; diff --git a/apps/web/app/future/(layout)/settings/developer/webhooks/page.tsx b/apps/web/app/future/(layout)/settings/developer/webhooks/page.tsx index 3c793169ddd8c0..4814ed74932ef3 100644 --- a/apps/web/app/future/(layout)/settings/developer/webhooks/page.tsx +++ b/apps/web/app/future/(layout)/settings/developer/webhooks/page.tsx @@ -1,39 +1,6 @@ import WebhooksPage from "@pages/settings/developer/webhooks"; -import { headers } from "next/headers"; +import { _generateMetadata } from "app/_utils"; -import { constructGenericImage } from "@calcom/lib/OgImages"; -import { IS_CALCOM, WEBAPP_URL, APP_NAME, SEO_IMG_OGIMG } from "@calcom/lib/constants"; -import { getFixedT } from "@calcom/lib/server/getFixedT"; - -import { preparePageMetadata } from "@lib/metadata"; - -export const generateMetadata = async () => { - const h = headers(); - const canonical = h.get("x-pathname") ?? ""; - const locale = h.get("x-locale") ?? "en"; - - const t = await getFixedT(locale, "common"); - - const title = t("webhooks"); - const description = t("add_webhook_description"); - - const metadataBase = new URL(IS_CALCOM ? "https://cal.com" : WEBAPP_URL); - - const image = - SEO_IMG_OGIMG + - constructGenericImage({ - title, - description, - }); - - return preparePageMetadata({ - title, - canonical, - image, - description, - siteName: APP_NAME, - metadataBase, - }); -}; +export const generateMetadata = async () => await _generateMetadata("webhooks", "add_webhook_description"); export default WebhooksPage; diff --git a/apps/web/app/future/(layout)/settings/my-account/appearance/page.tsx b/apps/web/app/future/(layout)/settings/my-account/appearance/page.tsx index d6bb1d28f68ed4..ef95e123b05cc6 100644 --- a/apps/web/app/future/(layout)/settings/my-account/appearance/page.tsx +++ b/apps/web/app/future/(layout)/settings/my-account/appearance/page.tsx @@ -1,39 +1,6 @@ import AppearancePage from "@pages/settings/my-account/appearance"; -import { headers } from "next/headers"; +import { _generateMetadata } from "app/_utils"; -import { constructGenericImage } from "@calcom/lib/OgImages"; -import { IS_CALCOM, WEBAPP_URL, APP_NAME, SEO_IMG_OGIMG } from "@calcom/lib/constants"; -import { getFixedT } from "@calcom/lib/server/getFixedT"; - -import { preparePageMetadata } from "@lib/metadata"; - -export const generateMetadata = async () => { - const h = headers(); - const canonical = h.get("x-pathname") ?? ""; - const locale = h.get("x-locale") ?? "en"; - - const t = await getFixedT(locale, "common"); - - const title = t("appearance"); - const description = t("appearance_description"); - - const metadataBase = new URL(IS_CALCOM ? "https://cal.com" : WEBAPP_URL); - - const image = - SEO_IMG_OGIMG + - constructGenericImage({ - title, - description, - }); - - return preparePageMetadata({ - title, - canonical, - image, - description, - siteName: APP_NAME, - metadataBase, - }); -}; +export const generateMetadata = async () => await _generateMetadata("appearance", "appearance_description"); export default AppearancePage; diff --git a/apps/web/app/future/(layout)/settings/my-account/calendars/page.tsx b/apps/web/app/future/(layout)/settings/my-account/calendars/page.tsx index 0e20b68289f5e5..bdc185a382de82 100644 --- a/apps/web/app/future/(layout)/settings/my-account/calendars/page.tsx +++ b/apps/web/app/future/(layout)/settings/my-account/calendars/page.tsx @@ -1,39 +1,6 @@ import CalendarsPage from "@pages/settings/my-account/calendars"; -import { headers } from "next/headers"; +import { _generateMetadata } from "app/_utils"; -import { constructGenericImage } from "@calcom/lib/OgImages"; -import { IS_CALCOM, WEBAPP_URL, APP_NAME, SEO_IMG_OGIMG } from "@calcom/lib/constants"; -import { getFixedT } from "@calcom/lib/server/getFixedT"; - -import { preparePageMetadata } from "@lib/metadata"; - -export const generateMetadata = async () => { - const h = headers(); - const canonical = h.get("x-pathname") ?? ""; - const locale = h.get("x-locale") ?? "en"; - - const t = await getFixedT(locale, "common"); - - const title = t("calendars"); - const description = t("calendars_description"); - - const metadataBase = new URL(IS_CALCOM ? "https://cal.com" : WEBAPP_URL); - - const image = - SEO_IMG_OGIMG + - constructGenericImage({ - title, - description, - }); - - return preparePageMetadata({ - title, - canonical, - image, - description, - siteName: APP_NAME, - metadataBase, - }); -}; +export const generateMetadata = async () => await _generateMetadata("calendars", "calendars_description"); export default CalendarsPage; diff --git a/apps/web/app/future/(layout)/settings/my-account/conferencing/page.tsx b/apps/web/app/future/(layout)/settings/my-account/conferencing/page.tsx index 65d3c99ec7ce23..3ed186e2dcd5cd 100644 --- a/apps/web/app/future/(layout)/settings/my-account/conferencing/page.tsx +++ b/apps/web/app/future/(layout)/settings/my-account/conferencing/page.tsx @@ -1,39 +1,7 @@ import ConferencingPage from "@pages/settings/my-account/conferencing"; -import { headers } from "next/headers"; +import { _generateMetadata } from "app/_utils"; -import { constructGenericImage } from "@calcom/lib/OgImages"; -import { IS_CALCOM, WEBAPP_URL, APP_NAME, SEO_IMG_OGIMG } from "@calcom/lib/constants"; -import { getFixedT } from "@calcom/lib/server/getFixedT"; - -import { preparePageMetadata } from "@lib/metadata"; - -export const generateMetadata = async () => { - const h = headers(); - const canonical = h.get("x-pathname") ?? ""; - const locale = h.get("x-locale") ?? "en"; - - const t = await getFixedT(locale, "common"); - - const title = t("conferencing"); - const description = t("conferencing_description"); - - const metadataBase = new URL(IS_CALCOM ? "https://cal.com" : WEBAPP_URL); - - const image = - SEO_IMG_OGIMG + - constructGenericImage({ - title, - description, - }); - - return preparePageMetadata({ - title, - canonical, - image, - description, - siteName: APP_NAME, - metadataBase, - }); -}; +export const generateMetadata = async () => + await _generateMetadata("conferencing", "conferencing_description"); export default ConferencingPage; diff --git a/apps/web/app/future/(layout)/settings/my-account/general/page.tsx b/apps/web/app/future/(layout)/settings/my-account/general/page.tsx index 57f53d6ad7e94b..e950e59828273a 100644 --- a/apps/web/app/future/(layout)/settings/my-account/general/page.tsx +++ b/apps/web/app/future/(layout)/settings/my-account/general/page.tsx @@ -1,39 +1,6 @@ import GeneralPage from "@pages/settings/my-account/general"; -import { headers } from "next/headers"; +import { _generateMetadata } from "app/_utils"; -import { constructGenericImage } from "@calcom/lib/OgImages"; -import { IS_CALCOM, WEBAPP_URL, APP_NAME, SEO_IMG_OGIMG } from "@calcom/lib/constants"; -import { getFixedT } from "@calcom/lib/server/getFixedT"; - -import { preparePageMetadata } from "@lib/metadata"; - -export const generateMetadata = async () => { - const h = headers(); - const canonical = h.get("x-pathname") ?? ""; - const locale = h.get("x-locale") ?? "en"; - - const t = await getFixedT(locale, "common"); - - const title = t("general"); - const description = t("general_description"); - - const metadataBase = new URL(IS_CALCOM ? "https://cal.com" : WEBAPP_URL); - - const image = - SEO_IMG_OGIMG + - constructGenericImage({ - title, - description, - }); - - return preparePageMetadata({ - title, - canonical, - image, - description, - siteName: APP_NAME, - metadataBase, - }); -}; +export const generateMetadata = async () => await _generateMetadata("general", "general_description"); export default GeneralPage; diff --git a/apps/web/app/future/(layout)/settings/my-account/profile/page.tsx b/apps/web/app/future/(layout)/settings/my-account/profile/page.tsx index 9ae537ec0b6f55..e22fafa4f0e5da 100644 --- a/apps/web/app/future/(layout)/settings/my-account/profile/page.tsx +++ b/apps/web/app/future/(layout)/settings/my-account/profile/page.tsx @@ -1,39 +1,6 @@ import ProfilePage from "@pages/settings/my-account/profile"; -import { headers } from "next/headers"; +import { _generateMetadata } from "app/_utils"; -import { constructGenericImage } from "@calcom/lib/OgImages"; -import { IS_CALCOM, WEBAPP_URL, APP_NAME, SEO_IMG_OGIMG } from "@calcom/lib/constants"; -import { getFixedT } from "@calcom/lib/server/getFixedT"; - -import { preparePageMetadata } from "@lib/metadata"; - -export const generateMetadata = async () => { - const h = headers(); - const canonical = h.get("x-pathname") ?? ""; - const locale = h.get("x-locale") ?? "en"; - - const t = await getFixedT(locale, "common"); - - const title = t("profile"); - const description = t("profile_description", { appName: APP_NAME }); - - const metadataBase = new URL(IS_CALCOM ? "https://cal.com" : WEBAPP_URL); - - const image = - SEO_IMG_OGIMG + - constructGenericImage({ - title, - description, - }); - - return preparePageMetadata({ - title, - canonical, - image, - description, - siteName: APP_NAME, - metadataBase, - }); -}; +export const generateMetadata = async () => await _generateMetadata("profile", "profile_description"); export default ProfilePage; diff --git a/apps/web/app/future/(layout)/settings/security/impersonation/page.tsx b/apps/web/app/future/(layout)/settings/security/impersonation/page.tsx index 8ae3243fe77382..3c6566a8f37b3a 100644 --- a/apps/web/app/future/(layout)/settings/security/impersonation/page.tsx +++ b/apps/web/app/future/(layout)/settings/security/impersonation/page.tsx @@ -1,39 +1,7 @@ import ImpersonationPage from "@pages/settings/security/impersonation"; -import { headers } from "next/headers"; +import { _generateMetadata } from "app/_utils"; -import { constructGenericImage } from "@calcom/lib/OgImages"; -import { IS_CALCOM, WEBAPP_URL, APP_NAME, SEO_IMG_OGIMG } from "@calcom/lib/constants"; -import { getFixedT } from "@calcom/lib/server/getFixedT"; - -import { preparePageMetadata } from "@lib/metadata"; - -export const generateMetadata = async () => { - const h = headers(); - const canonical = h.get("x-pathname") ?? ""; - const locale = h.get("x-locale") ?? "en"; - - const t = await getFixedT(locale, "common"); - - const title = t("impersonation"); - const description = t("impersonation_description"); - - const metadataBase = new URL(IS_CALCOM ? "https://cal.com" : WEBAPP_URL); - - const image = - SEO_IMG_OGIMG + - constructGenericImage({ - title, - description, - }); - - return preparePageMetadata({ - title, - canonical, - image, - description, - siteName: APP_NAME, - metadataBase, - }); -}; +export const generateMetadata = async () => + await _generateMetadata("impersonation", "impersonation_description"); export default ImpersonationPage; diff --git a/apps/web/app/future/(layout)/settings/security/password/page.tsx b/apps/web/app/future/(layout)/settings/security/password/page.tsx index 222394d85729fc..f7be2443de5f19 100644 --- a/apps/web/app/future/(layout)/settings/security/password/page.tsx +++ b/apps/web/app/future/(layout)/settings/security/password/page.tsx @@ -1,39 +1,6 @@ import PasswordPage from "@pages/settings/security/password"; -import { headers } from "next/headers"; +import { _generateMetadata } from "app/_utils"; -import { constructGenericImage } from "@calcom/lib/OgImages"; -import { IS_CALCOM, WEBAPP_URL, APP_NAME, SEO_IMG_OGIMG } from "@calcom/lib/constants"; -import { getFixedT } from "@calcom/lib/server/getFixedT"; - -import { preparePageMetadata } from "@lib/metadata"; - -export const generateMetadata = async () => { - const h = headers(); - const canonical = h.get("x-pathname") ?? ""; - const locale = h.get("x-locale") ?? "en"; - - const t = await getFixedT(locale, "common"); - - const title = t("password"); - const description = t("password_description"); - - const metadataBase = new URL(IS_CALCOM ? "https://cal.com" : WEBAPP_URL); - - const image = - SEO_IMG_OGIMG + - constructGenericImage({ - title, - description, - }); - - return preparePageMetadata({ - title, - canonical, - image, - description, - siteName: APP_NAME, - metadataBase, - }); -}; +export const generateMetadata = async () => await _generateMetadata("password", "password_description"); export default PasswordPage; diff --git a/apps/web/app/future/(layout)/settings/security/two-factor-auth/page.tsx b/apps/web/app/future/(layout)/settings/security/two-factor-auth/page.tsx index dbfe2bcd6fcc75..7ce41e943d872b 100644 --- a/apps/web/app/future/(layout)/settings/security/two-factor-auth/page.tsx +++ b/apps/web/app/future/(layout)/settings/security/two-factor-auth/page.tsx @@ -1,39 +1,7 @@ import TwoFactorAuthPage from "@pages/settings/security/two-factor-auth"; -import { headers } from "next/headers"; +import { _generateMetadata } from "app/_utils"; -import { constructGenericImage } from "@calcom/lib/OgImages"; -import { IS_CALCOM, WEBAPP_URL, APP_NAME, SEO_IMG_OGIMG } from "@calcom/lib/constants"; -import { getFixedT } from "@calcom/lib/server/getFixedT"; - -import { preparePageMetadata } from "@lib/metadata"; - -export const generateMetadata = async () => { - const h = headers(); - const canonical = h.get("x-pathname") ?? ""; - const locale = h.get("x-locale") ?? "en"; - - const t = await getFixedT(locale, "common"); - - const title = t("two_factor_auth"); - const description = t("add_an_extra_layer_of_security"); - - const metadataBase = new URL(IS_CALCOM ? "https://cal.com" : WEBAPP_URL); - - const image = - SEO_IMG_OGIMG + - constructGenericImage({ - title, - description, - }); - - return preparePageMetadata({ - title, - canonical, - image, - description, - siteName: APP_NAME, - metadataBase, - }); -}; +export const generateMetadata = async () => + await _generateMetadata("two_factor_auth", "add_an_extra_layer_of_security"); export default TwoFactorAuthPage; diff --git a/apps/web/app/future/(layout)/workflows/page.tsx b/apps/web/app/future/(layout)/workflows/page.tsx index 876bf747f921ef..67b17c736f4d40 100644 --- a/apps/web/app/future/(layout)/workflows/page.tsx +++ b/apps/web/app/future/(layout)/workflows/page.tsx @@ -1,42 +1,11 @@ -import { headers } from "next/headers"; +import { _generateMetadata } from "app/_utils"; import Workflows from "@calcom/features/ee/workflows/pages/index"; -import { constructGenericImage } from "@calcom/lib/OgImages"; -import { IS_CALCOM, WEBAPP_URL, APP_NAME, SEO_IMG_OGIMG } from "@calcom/lib/constants"; -import { getFixedT } from "@calcom/lib/server/getFixedT"; - -import { preparePageMetadata } from "@lib/metadata"; import type { CalPageWrapper } from "@components/PageWrapper"; -export const generateMetadata = async () => { - const h = headers(); - const canonical = h.get("x-pathname") ?? ""; - const locale = h.get("x-locale") ?? "en"; - - const t = await getFixedT(locale, "common"); - - const title = t("workflows"); - const description = t("workflows_to_automate_notifications"); - - const metadataBase = new URL(IS_CALCOM ? "https://cal.com" : WEBAPP_URL); - - const image = - SEO_IMG_OGIMG + - constructGenericImage({ - title, - description, - }); - - return preparePageMetadata({ - title, - canonical, - image, - description, - siteName: APP_NAME, - metadataBase, - }); -}; +export const generateMetadata = async () => + await _generateMetadata("workflows", "workflows_to_automate_notifications"); const WorkflowsPage = Workflows as CalPageWrapper; diff --git a/apps/web/app/future/(no-layout)/video/page.tsx b/apps/web/app/future/(no-layout)/video/page.tsx index 9475e0511c2415..14e49bbd7a35f4 100644 --- a/apps/web/app/future/(no-layout)/video/page.tsx +++ b/apps/web/app/future/(no-layout)/video/page.tsx @@ -1,39 +1,7 @@ import NoMeetingFoundPage from "@pages/video/no-meeting-found"; -import { headers } from "next/headers"; +import { _generateMetadata } from "app/_utils"; -import { constructGenericImage } from "@calcom/lib/OgImages"; -import { IS_CALCOM, WEBAPP_URL, APP_NAME, SEO_IMG_OGIMG } from "@calcom/lib/constants"; -import { getFixedT } from "@calcom/lib/server/getFixedT"; - -import { preparePageMetadata } from "@lib/metadata"; - -export const generateMetadata = async () => { - const h = headers(); - const canonical = h.get("x-pathname") ?? ""; - const locale = h.get("x-locale") ?? "en"; - - const t = await getFixedT(locale, "common"); - - const title = t("no_meeting_found"); - const description = t("no_meeting_found_description"); - - const metadataBase = new URL(IS_CALCOM ? "https://cal.com" : WEBAPP_URL); - - const image = - SEO_IMG_OGIMG + - constructGenericImage({ - title, - description, - }); - - return preparePageMetadata({ - title, - canonical, - image, - description, - siteName: APP_NAME, - metadataBase, - }); -}; +export const generateMetadata = async () => + await _generateMetadata("no_meeting_found", "no_meeting_found_description"); export default NoMeetingFoundPage; From c3fadd6b298ad150f7acc05de09e030115966445 Mon Sep 17 00:00:00 2001 From: Benny Joo Date: Wed, 1 Nov 2023 16:57:58 +0000 Subject: [PATCH 3/4] address comment --- apps/web/app/_utils.tsx | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/apps/web/app/_utils.tsx b/apps/web/app/_utils.tsx index 43e0af6c30b0cf..da2b3895932368 100644 --- a/apps/web/app/_utils.tsx +++ b/apps/web/app/_utils.tsx @@ -1,3 +1,4 @@ +import { type TFunction } from "i18next"; import { headers } from "next/headers"; import { constructGenericImage } from "@calcom/lib/OgImages"; @@ -7,10 +8,8 @@ import { getFixedT } from "@calcom/lib/server/getFixedT"; import { preparePageMetadata } from "@lib/metadata"; export const _generateMetadata = async ( - titleKey: string, - descriptionKey: string, - usePlainTitleKey?: boolean, - usePlainDescriptionKey?: boolean + getTitle: (t: TFunction) => string, + getDescription: (t: TFunction) => string ) => { const h = headers(); const canonical = h.get("x-pathname") ?? ""; @@ -18,8 +17,8 @@ export const _generateMetadata = async ( const t = await getFixedT(locale, "common"); - const title = usePlainTitleKey ? titleKey : t(titleKey); - const description = usePlainDescriptionKey ? descriptionKey : t(descriptionKey); + const title = getTitle(t); + const description = getDescription(t); const metadataBase = new URL(IS_CALCOM ? "https://cal.com" : WEBAPP_URL); From 32ed376624d289c3c49c9fbe9ab5a86ff81e1655 Mon Sep 17 00:00:00 2001 From: Benny Joo Date: Wed, 1 Nov 2023 16:58:12 +0000 Subject: [PATCH 4/4] Use the new util --- apps/web/app/future/(layout)/availability/page.tsx | 6 +++++- apps/web/app/future/(layout)/event-types/page.tsx | 5 ++++- apps/web/app/future/(layout)/insights/page.tsx | 6 +++++- apps/web/app/future/(layout)/settings/billing/page.tsx | 6 +++++- .../future/(layout)/settings/developer/webhooks/page.tsx | 6 +++++- .../future/(layout)/settings/my-account/appearance/page.tsx | 6 +++++- .../future/(layout)/settings/my-account/calendars/page.tsx | 6 +++++- .../(layout)/settings/my-account/conferencing/page.tsx | 5 ++++- .../future/(layout)/settings/my-account/general/page.tsx | 6 +++++- .../future/(layout)/settings/my-account/profile/page.tsx | 6 +++++- .../(layout)/settings/security/impersonation/page.tsx | 5 ++++- .../app/future/(layout)/settings/security/password/page.tsx | 6 +++++- .../(layout)/settings/security/two-factor-auth/page.tsx | 5 ++++- apps/web/app/future/(layout)/workflows/page.tsx | 5 ++++- apps/web/app/future/(no-layout)/video/page.tsx | 5 ++++- 15 files changed, 69 insertions(+), 15 deletions(-) diff --git a/apps/web/app/future/(layout)/availability/page.tsx b/apps/web/app/future/(layout)/availability/page.tsx index 17a8a3013fb546..101de73b1399a0 100644 --- a/apps/web/app/future/(layout)/availability/page.tsx +++ b/apps/web/app/future/(layout)/availability/page.tsx @@ -1,6 +1,10 @@ import AvailabilityPage from "@pages/availability"; import { _generateMetadata } from "app/_utils"; -export const generateMetadata = async () => await _generateMetadata("availability", "configure_availability"); +export const generateMetadata = async () => + await _generateMetadata( + (t) => t("availability"), + (t) => t("configure_availability") + ); export default AvailabilityPage; diff --git a/apps/web/app/future/(layout)/event-types/page.tsx b/apps/web/app/future/(layout)/event-types/page.tsx index 0d7ed87d3a919d..246bcc5c906e23 100644 --- a/apps/web/app/future/(layout)/event-types/page.tsx +++ b/apps/web/app/future/(layout)/event-types/page.tsx @@ -2,6 +2,9 @@ import EventTypes from "@pages/event-types"; import { _generateMetadata } from "app/_utils"; export const generateMetadata = async () => - await _generateMetadata("event_types_page_title", "event_types_page_subtitle"); + await _generateMetadata( + (t) => t("event_types_page_title"), + (t) => t("event_types_page_subtitle") + ); export default EventTypes; diff --git a/apps/web/app/future/(layout)/insights/page.tsx b/apps/web/app/future/(layout)/insights/page.tsx index 29190bd85c1723..a60abccc7d274e 100644 --- a/apps/web/app/future/(layout)/insights/page.tsx +++ b/apps/web/app/future/(layout)/insights/page.tsx @@ -1,6 +1,10 @@ import InsightsPage from "@pages/insights"; import { _generateMetadata } from "app/_utils"; -export const generateMetadata = async () => await _generateMetadata("Insights", "insights_subtitle", true); +export const generateMetadata = async () => + await _generateMetadata( + () => "Insights", + (t) => t("insights_subtitle") + ); export default InsightsPage; diff --git a/apps/web/app/future/(layout)/settings/billing/page.tsx b/apps/web/app/future/(layout)/settings/billing/page.tsx index 3e8dfad88ca788..0a62a22071e512 100644 --- a/apps/web/app/future/(layout)/settings/billing/page.tsx +++ b/apps/web/app/future/(layout)/settings/billing/page.tsx @@ -1,6 +1,10 @@ import BillingPage from "@pages/settings/billing"; import { _generateMetadata } from "app/_utils"; -export const generateMetadata = async () => await _generateMetadata("billing", "manage_billing_description"); +export const generateMetadata = async () => + await _generateMetadata( + (t) => t("billing"), + (t) => t("manage_billing_description") + ); export default BillingPage; diff --git a/apps/web/app/future/(layout)/settings/developer/webhooks/page.tsx b/apps/web/app/future/(layout)/settings/developer/webhooks/page.tsx index 4814ed74932ef3..b832b9caa3746f 100644 --- a/apps/web/app/future/(layout)/settings/developer/webhooks/page.tsx +++ b/apps/web/app/future/(layout)/settings/developer/webhooks/page.tsx @@ -1,6 +1,10 @@ import WebhooksPage from "@pages/settings/developer/webhooks"; import { _generateMetadata } from "app/_utils"; -export const generateMetadata = async () => await _generateMetadata("webhooks", "add_webhook_description"); +export const generateMetadata = async () => + await _generateMetadata( + (t) => t("webhooks"), + (t) => t("add_webhook_description") + ); export default WebhooksPage; diff --git a/apps/web/app/future/(layout)/settings/my-account/appearance/page.tsx b/apps/web/app/future/(layout)/settings/my-account/appearance/page.tsx index ef95e123b05cc6..036a70c13008ac 100644 --- a/apps/web/app/future/(layout)/settings/my-account/appearance/page.tsx +++ b/apps/web/app/future/(layout)/settings/my-account/appearance/page.tsx @@ -1,6 +1,10 @@ import AppearancePage from "@pages/settings/my-account/appearance"; import { _generateMetadata } from "app/_utils"; -export const generateMetadata = async () => await _generateMetadata("appearance", "appearance_description"); +export const generateMetadata = async () => + await _generateMetadata( + (t) => t("appearance"), + (t) => t("appearance_description") + ); export default AppearancePage; diff --git a/apps/web/app/future/(layout)/settings/my-account/calendars/page.tsx b/apps/web/app/future/(layout)/settings/my-account/calendars/page.tsx index bdc185a382de82..42e37be30cdb29 100644 --- a/apps/web/app/future/(layout)/settings/my-account/calendars/page.tsx +++ b/apps/web/app/future/(layout)/settings/my-account/calendars/page.tsx @@ -1,6 +1,10 @@ import CalendarsPage from "@pages/settings/my-account/calendars"; import { _generateMetadata } from "app/_utils"; -export const generateMetadata = async () => await _generateMetadata("calendars", "calendars_description"); +export const generateMetadata = async () => + await _generateMetadata( + (t) => t("calendars"), + (t) => t("calendars_description") + ); export default CalendarsPage; diff --git a/apps/web/app/future/(layout)/settings/my-account/conferencing/page.tsx b/apps/web/app/future/(layout)/settings/my-account/conferencing/page.tsx index 3ed186e2dcd5cd..8903e6a6e7033b 100644 --- a/apps/web/app/future/(layout)/settings/my-account/conferencing/page.tsx +++ b/apps/web/app/future/(layout)/settings/my-account/conferencing/page.tsx @@ -2,6 +2,9 @@ import ConferencingPage from "@pages/settings/my-account/conferencing"; import { _generateMetadata } from "app/_utils"; export const generateMetadata = async () => - await _generateMetadata("conferencing", "conferencing_description"); + await _generateMetadata( + (t) => t("conferencing"), + (t) => t("conferencing_description") + ); export default ConferencingPage; diff --git a/apps/web/app/future/(layout)/settings/my-account/general/page.tsx b/apps/web/app/future/(layout)/settings/my-account/general/page.tsx index e950e59828273a..c0d1c2cdc2e3c4 100644 --- a/apps/web/app/future/(layout)/settings/my-account/general/page.tsx +++ b/apps/web/app/future/(layout)/settings/my-account/general/page.tsx @@ -1,6 +1,10 @@ import GeneralPage from "@pages/settings/my-account/general"; import { _generateMetadata } from "app/_utils"; -export const generateMetadata = async () => await _generateMetadata("general", "general_description"); +export const generateMetadata = async () => + await _generateMetadata( + (t) => t("general"), + (t) => t("general_description") + ); export default GeneralPage; diff --git a/apps/web/app/future/(layout)/settings/my-account/profile/page.tsx b/apps/web/app/future/(layout)/settings/my-account/profile/page.tsx index e22fafa4f0e5da..89073d74bb27f9 100644 --- a/apps/web/app/future/(layout)/settings/my-account/profile/page.tsx +++ b/apps/web/app/future/(layout)/settings/my-account/profile/page.tsx @@ -1,6 +1,10 @@ import ProfilePage from "@pages/settings/my-account/profile"; import { _generateMetadata } from "app/_utils"; -export const generateMetadata = async () => await _generateMetadata("profile", "profile_description"); +export const generateMetadata = async () => + await _generateMetadata( + (t) => t("profile"), + (t) => t("profile_description") + ); export default ProfilePage; diff --git a/apps/web/app/future/(layout)/settings/security/impersonation/page.tsx b/apps/web/app/future/(layout)/settings/security/impersonation/page.tsx index 3c6566a8f37b3a..c96c23e15722d7 100644 --- a/apps/web/app/future/(layout)/settings/security/impersonation/page.tsx +++ b/apps/web/app/future/(layout)/settings/security/impersonation/page.tsx @@ -2,6 +2,9 @@ import ImpersonationPage from "@pages/settings/security/impersonation"; import { _generateMetadata } from "app/_utils"; export const generateMetadata = async () => - await _generateMetadata("impersonation", "impersonation_description"); + await _generateMetadata( + (t) => t("impersonation"), + (t) => t("impersonation_description") + ); export default ImpersonationPage; diff --git a/apps/web/app/future/(layout)/settings/security/password/page.tsx b/apps/web/app/future/(layout)/settings/security/password/page.tsx index f7be2443de5f19..c3e0a2c7b1f12d 100644 --- a/apps/web/app/future/(layout)/settings/security/password/page.tsx +++ b/apps/web/app/future/(layout)/settings/security/password/page.tsx @@ -1,6 +1,10 @@ import PasswordPage from "@pages/settings/security/password"; import { _generateMetadata } from "app/_utils"; -export const generateMetadata = async () => await _generateMetadata("password", "password_description"); +export const generateMetadata = async () => + await _generateMetadata( + (t) => t("password"), + (t) => t("password_description") + ); export default PasswordPage; diff --git a/apps/web/app/future/(layout)/settings/security/two-factor-auth/page.tsx b/apps/web/app/future/(layout)/settings/security/two-factor-auth/page.tsx index 7ce41e943d872b..d73909dc5f40e1 100644 --- a/apps/web/app/future/(layout)/settings/security/two-factor-auth/page.tsx +++ b/apps/web/app/future/(layout)/settings/security/two-factor-auth/page.tsx @@ -2,6 +2,9 @@ import TwoFactorAuthPage from "@pages/settings/security/two-factor-auth"; import { _generateMetadata } from "app/_utils"; export const generateMetadata = async () => - await _generateMetadata("two_factor_auth", "add_an_extra_layer_of_security"); + await _generateMetadata( + (t) => t("two_factor_auth"), + (t) => t("add_an_extra_layer_of_security") + ); export default TwoFactorAuthPage; diff --git a/apps/web/app/future/(layout)/workflows/page.tsx b/apps/web/app/future/(layout)/workflows/page.tsx index 67b17c736f4d40..819809be0d366a 100644 --- a/apps/web/app/future/(layout)/workflows/page.tsx +++ b/apps/web/app/future/(layout)/workflows/page.tsx @@ -5,7 +5,10 @@ import Workflows from "@calcom/features/ee/workflows/pages/index"; import type { CalPageWrapper } from "@components/PageWrapper"; export const generateMetadata = async () => - await _generateMetadata("workflows", "workflows_to_automate_notifications"); + await _generateMetadata( + (t) => t("workflows"), + (t) => t("workflows_to_automate_notifications") + ); const WorkflowsPage = Workflows as CalPageWrapper; diff --git a/apps/web/app/future/(no-layout)/video/page.tsx b/apps/web/app/future/(no-layout)/video/page.tsx index 14e49bbd7a35f4..baae420f349f93 100644 --- a/apps/web/app/future/(no-layout)/video/page.tsx +++ b/apps/web/app/future/(no-layout)/video/page.tsx @@ -2,6 +2,9 @@ import NoMeetingFoundPage from "@pages/video/no-meeting-found"; import { _generateMetadata } from "app/_utils"; export const generateMetadata = async () => - await _generateMetadata("no_meeting_found", "no_meeting_found_description"); + await _generateMetadata( + (t) => t("no_meeting_found"), + (t) => t("no_meeting_found_description") + ); export default NoMeetingFoundPage;