Skip to content

Commit 9b9d2dd

Browse files
committed
Configurable Tailwind based shadows; Github Icon in header;
1 parent 68cd78a commit 9b9d2dd

41 files changed

Lines changed: 2294 additions & 1024 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

apps/web/app/(with-contexts)/(with-layout)/home-page-layout.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
TypefacesContext,
99
ThemeContext,
1010
} from "@components/contexts";
11-
import { MasterLayout } from "@components/public/base-layout";
11+
import { BaseLayout } from "@components/public/base-layout";
1212
import { Profile } from "@courselit/common-models";
1313
import { getPage } from "@ui-lib/utils";
1414
import { useContext, useEffect, useState } from "react";
@@ -37,7 +37,7 @@ export default function HomepageLayout({
3737
}
3838

3939
return (
40-
<MasterLayout
40+
<BaseLayout
4141
layout={page.layout}
4242
title={page.title}
4343
typefaces={typefaces}
@@ -69,6 +69,6 @@ export default function HomepageLayout({
6969
}}
7070
>
7171
{children}
72-
</MasterLayout>
72+
</BaseLayout>
7373
);
7474
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
"use client";
2+
3+
import { useContext } from "react";
4+
import {
5+
AddressContext,
6+
ServerConfigContext,
7+
TypefacesContext,
8+
} from "@components/contexts";
9+
import { ProfileContext } from "@components/contexts";
10+
import { BaseLayout } from "@components/public/base-layout";
11+
import { Profile } from "@courselit/common-models";
12+
13+
export default function ClientSidePage({
14+
page,
15+
siteinfo,
16+
theme,
17+
}: {
18+
page;
19+
siteinfo;
20+
theme;
21+
}) {
22+
const typefaces = useContext(TypefacesContext);
23+
const config = useContext(ServerConfigContext);
24+
const { profile } = useContext(ProfileContext);
25+
const address = useContext(AddressContext);
26+
27+
if (!page) {
28+
return null;
29+
}
30+
31+
const layoutWithoutHeaderFooter = page?.layout
32+
?.filter((layout: any) => !["header", "footer"].includes(layout.name))
33+
?.map((layout: any) => ({
34+
...layout,
35+
settings: layout.settings || {},
36+
}));
37+
38+
return (
39+
<BaseLayout
40+
layout={layoutWithoutHeaderFooter}
41+
title={page.title || page.pageData?.title}
42+
pageData={page.pageData}
43+
typefaces={typefaces}
44+
siteInfo={siteinfo}
45+
dispatch={() => {}}
46+
theme={theme}
47+
state={{
48+
config: config,
49+
siteinfo,
50+
address,
51+
profile: profile as Profile,
52+
auth: profile.email
53+
? {
54+
guest: false,
55+
checked: true,
56+
}
57+
: {
58+
guest: true,
59+
checked: true,
60+
},
61+
networkAction: false,
62+
theme,
63+
typefaces,
64+
message: {
65+
message: "",
66+
open: false,
67+
action: null,
68+
},
69+
}}
70+
/>
71+
);
72+
}
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
import { getPage, getSiteInfo } from "@ui-lib/utils";
2+
import { getAddressFromHeaders } from "@/ui-lib/utils";
3+
import ClientSidePage from "./client-side-page";
4+
import { headers } from "next/headers";
5+
import type { Metadata, ResolvingMetadata } from "next";
6+
7+
type Props = {
8+
params: {
9+
id: string;
10+
};
11+
};
12+
13+
export async function generateMetadata(
14+
{ params }: Props,
15+
parent: ResolvingMetadata,
16+
): Promise<Metadata> {
17+
const address = getAddressFromHeaders(headers);
18+
const siteInfo = await getSiteInfo(address);
19+
if (!siteInfo) {
20+
return {
21+
title: `${(await parent)?.title?.absolute}`,
22+
};
23+
}
24+
25+
const page = await getPage(address, params.id);
26+
27+
const title = page.title || page.pageData?.title || page.name;
28+
const socialImage = page.socialImage || siteInfo.settings.logo;
29+
const description =
30+
page.description || (page.pageData?.description as string);
31+
32+
return {
33+
generator: "CourseLit",
34+
title: `${title} | ${(await parent)?.title?.absolute}`,
35+
description,
36+
openGraph: {
37+
title: `${title} | ${(await parent)?.title?.absolute}`,
38+
description,
39+
images: [
40+
{
41+
url: socialImage?.file || "",
42+
alt: socialImage?.caption || "",
43+
},
44+
],
45+
},
46+
twitter: {
47+
title: `${title} | ${(await parent)?.title?.absolute}`,
48+
description,
49+
images: [
50+
{
51+
url: socialImage?.file || "",
52+
alt: socialImage?.caption || "",
53+
},
54+
],
55+
},
56+
robots: {
57+
index: page.robotsAllowed,
58+
},
59+
icons: {
60+
icon: siteInfo.settings.logo?.file || "/favicon.ico",
61+
},
62+
};
63+
}
64+
65+
export default async function Page({ params }: Props) {
66+
const address = getAddressFromHeaders(headers);
67+
const siteInfo = await getSiteInfo(address);
68+
if (!siteInfo) {
69+
return null;
70+
}
71+
72+
const page = await getPage(address, params.id);
73+
74+
return (
75+
<ClientSidePage
76+
page={page}
77+
siteinfo={siteInfo.settings}
78+
theme={siteInfo.theme}
79+
/>
80+
);
81+
}
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
import { getPage, getSiteInfo } from "@ui-lib/utils";
2+
import { getAddressFromHeaders } from "@/ui-lib/utils";
3+
import ClientSidePage from "./p/[id]/client-side-page";
4+
import { headers } from "next/headers";
5+
import type { Metadata, ResolvingMetadata } from "next";
6+
7+
type Props = {
8+
params: {
9+
id: string;
10+
};
11+
};
12+
13+
export async function generateMetadata(
14+
{ params }: Props,
15+
parent: ResolvingMetadata,
16+
): Promise<Metadata> {
17+
const address = getAddressFromHeaders(headers);
18+
const siteInfo = await getSiteInfo(address);
19+
if (!siteInfo) {
20+
return {
21+
title: "CourseLit",
22+
};
23+
}
24+
25+
const page = await getPage(address, "homepage");
26+
27+
const title = page.title || siteInfo.settings.title;
28+
const socialImage = page.socialImage || siteInfo.settings.logo;
29+
const description = page.description || siteInfo.settings.subtitle;
30+
31+
return {
32+
generator: "CourseLit",
33+
title,
34+
description,
35+
openGraph: {
36+
title,
37+
description,
38+
images: [
39+
{
40+
url: socialImage?.file || "",
41+
alt: socialImage?.caption || "",
42+
},
43+
],
44+
},
45+
twitter: {
46+
title,
47+
description,
48+
images: [
49+
{
50+
url: socialImage?.file || "",
51+
alt: socialImage?.caption || "",
52+
},
53+
],
54+
},
55+
robots: {
56+
index: page.robotsAllowed,
57+
},
58+
icons: {
59+
icon: siteInfo.settings.logo?.file || "/favicon.ico",
60+
},
61+
};
62+
}
63+
64+
export default async function Page() {
65+
const address = getAddressFromHeaders(headers);
66+
const siteInfo = await getSiteInfo(address);
67+
if (!siteInfo) {
68+
return null;
69+
}
70+
71+
const page = await getPage(address, "homepage");
72+
73+
return (
74+
<ClientSidePage
75+
page={page}
76+
siteinfo={siteInfo.settings}
77+
theme={siteInfo.theme}
78+
/>
79+
);
80+
}

0 commit comments

Comments
 (0)