-
Notifications
You must be signed in to change notification settings - Fork 219
Expand file tree
/
Copy pathpage.tsx
More file actions
87 lines (80 loc) · 2.23 KB
/
page.tsx
File metadata and controls
87 lines (80 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import { getFullSiteSetup } from "@ui-lib/utils";
import { getAddressFromHeaders } from "@/app/actions";
import ClientSidePage from "./p/[id]/client-side-page";
import { headers } from "next/headers";
import type { Metadata, ResolvingMetadata } from "next";
import FirstRunPopup from "./first-run-popup";
type Props = {
params: {
id: string;
};
};
export async function generateMetadata(
{ params }: Props,
parent: ResolvingMetadata,
): Promise<Metadata> {
const address = await getAddressFromHeaders(headers);
const siteInfo = await getFullSiteSetup(address, "homepage");
if (!siteInfo) {
return {
title: "CourseLit",
};
}
const page = siteInfo.page;
const title = page.title || siteInfo.settings.title;
const socialImage = page.socialImage || siteInfo.settings.logo;
const description = page.description || siteInfo.settings.subtitle;
return {
generator: "CourseLit",
title,
description,
openGraph: {
title,
description,
images: [
{
url: socialImage?.file || "",
alt: socialImage?.caption || "",
},
],
},
twitter: {
title,
description,
images: [
{
url: socialImage?.file || "",
alt: socialImage?.caption || "",
},
],
},
robots: {
index: page.robotsAllowed,
},
icons: {
icon: siteInfo.settings.logo?.file || "/favicon.ico",
},
};
}
export default async function Page({
searchParams,
}: {
searchParams: Promise<{ firstrun?: string }>;
}) {
const address = await getAddressFromHeaders(headers);
const siteInfo = await getFullSiteSetup(address, "homepage");
if (!siteInfo) {
return null;
}
const firstRun = (await searchParams).firstrun === "1";
return (
<>
<ClientSidePage
page={siteInfo.page}
siteinfo={siteInfo.settings}
theme={siteInfo.theme}
/>
{firstRun && <FirstRunPopup />}
</>
);
}