Skip to content

Commit 489d56d

Browse files
authored
perf: Make /icons page a static page (calcom#23324)
* write _generateMetadataForStaticPage * refactor /icons/page.tsx
1 parent 532c2f5 commit 489d56d

2 files changed

Lines changed: 56 additions & 13 deletions

File tree

apps/web/app/_utils.tsx

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,48 @@ export const _generateMetadata = async (
8080
};
8181
};
8282

83+
export const _generateMetadataForStaticPage = (
84+
title: string,
85+
description: string,
86+
hideBranding?: boolean,
87+
origin?: string,
88+
pathname?: string
89+
) => {
90+
const _pathname = pathname ?? "";
91+
const canonical = buildCanonical({ path: _pathname, origin: origin ?? CAL_URL });
92+
const titleSuffix = `| ${APP_NAME}`;
93+
const displayedTitle = title.includes(titleSuffix) || hideBranding ? title : `${title} ${titleSuffix}`;
94+
const metadataBase = new URL(IS_CALCOM ? getCalcomUrl() : WEBAPP_URL);
95+
96+
const metadata = {
97+
title: title.length === 0 ? APP_NAME : displayedTitle,
98+
description,
99+
alternates: { canonical },
100+
openGraph: {
101+
description: truncateOnWord(description, 158),
102+
url: canonical,
103+
type: "website",
104+
siteName: APP_NAME,
105+
title: displayedTitle,
106+
},
107+
metadataBase,
108+
};
109+
const image =
110+
SEO_IMG_OGIMG +
111+
constructGenericImage({
112+
title: metadata.title,
113+
description: metadata.description,
114+
});
115+
116+
return {
117+
...metadata,
118+
openGraph: {
119+
...metadata.openGraph,
120+
images: [image],
121+
},
122+
};
123+
};
124+
83125
export const generateMeetingMetadata = async (
84126
meeting: MeetingImageProps,
85127
getTitle: (t: TFunction<string, undefined>) => string,

apps/web/app/icons/page.tsx

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { _generateMetadata, getTranslate } from "app/_utils";
1+
import { _generateMetadataForStaticPage } from "app/_utils";
2+
import type { Metadata } from "next";
23
import { Inter } from "next/font/google";
34
import localFont from "next/font/local";
45

@@ -8,6 +9,15 @@ import type { IconName } from "@calcom/ui/components/icon";
89
import { lucideIconList } from "../../../../packages/ui/components/icon/icon-list.mjs";
910
import { IconGrid } from "./IconGrid";
1011

12+
export const dynamic = "force-static";
13+
export const metadata: Metadata = _generateMetadataForStaticPage(
14+
"Icons Showcase",
15+
"",
16+
undefined,
17+
undefined,
18+
"/icons"
19+
);
20+
1121
const interFont = Inter({ subsets: ["latin"], variable: "--font-inter", preload: true, display: "swap" });
1222
const calFont = localFont({
1323
src: "../../fonts/CalSans-SemiBold.woff2",
@@ -16,25 +26,16 @@ const calFont = localFont({
1626
display: "swap",
1727
weight: "600",
1828
});
19-
export const generateMetadata = async () => {
20-
return await _generateMetadata(
21-
(t) => t("icon_showcase"),
22-
() => "",
23-
undefined,
24-
undefined,
25-
"/icons"
26-
);
27-
};
28-
export default async function IconsPage() {
29+
30+
export default function IconsPage() {
2931
const icons = Array.from(lucideIconList).sort() as IconName[];
30-
const t = await getTranslate();
3132

3233
return (
3334
<div className={`${interFont.variable} ${calFont.variable}`}>
3435
<div className="bg-subtle flex h-screen">
3536
<IconSprites />
3637
<div className="bg-default m-auto min-w-full rounded-md p-10 text-right ltr:text-left">
37-
<h1 className="text-emphasis font-cal text-2xl font-medium">{t("icons_showcase")}</h1>
38+
<h1 className="text-emphasis font-cal text-2xl font-medium">Icons Showcase</h1>
3839
<IconGrid title="Regular Icons" icons={icons} />
3940
<IconGrid
4041
title="Filled Icons"

0 commit comments

Comments
 (0)