Skip to content

Commit 0ae4ae1

Browse files
authored
Deploy v3 (#401)
* feat: add docsearch (#396) * Feat: add sitemap (#398) * fix: doc version links
1 parent 5342147 commit 0ae4ae1

22 files changed

+417
-74
lines changed

pwa/api/doc/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ export const loadV2DocumentationNav = cache(async (branch: string) => {
120120

121121
const navData: Chapters = YAML.parse(result.toString());
122122

123-
const basePath = branch === current ? `/docs` : `/docs/${branch}`;
123+
const basePath = branch === current ? `/docs` : `/docs/v${branch}`;
124124
return Promise.all(
125125
navData.chapters.map(async (part) => ({
126126
title: part.title,

pwa/app/(common)/community/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ export default async function Page() {
170170
</Heading>
171171
<div className="grid grid-cols-1 my-4 place-content-center lg:grid-cols-2 gap-4 sm:gap-6">
172172
{events.map((event: Event) => (
173-
<EventCard key={event.title} event={event} />
173+
<EventCard key={event.link} event={event} />
174174
))}
175175
</div>
176176
<ArrowLink

pwa/app/(common)/docs/[...slug]/layout.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ async function Layout({
1212
};
1313
children: React.ReactNode;
1414
}) {
15-
const version = versions.includes(slug[0]) ? slug[0] : current;
15+
const version = versions.includes(slug[0].substring(1))
16+
? slug[0].substring(1)
17+
: current;
1618
const nav = await loadV2DocumentationNav(version);
1719

1820
return <DocLayout nav={nav}>{children}</DocLayout>;

pwa/app/(common)/docs/[...slug]/page.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@ export async function generateStaticParams() {
2525
});
2626
}
2727
}
28-
for (const version of versions) {
29-
slugs.push({ slug: [version] });
30-
}
3128
return slugs;
3229
}
3330

@@ -60,7 +57,7 @@ export default async function Page({
6057
const breadCrumbs = [
6158
{
6259
title: version,
63-
link: version === current ? `/docs/${version}` : "/docs",
60+
link: version === current ? `/docs/v${version}` : "/docs",
6461
},
6562
{ title },
6663
];

pwa/app/(common)/events/components/EventsPage.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ export default function EventsPage({ events }: EventsPageProps) {
107107
{year}
108108
</Heading>
109109
<div className="grid grid-cols-1 place-content-center lg:grid-cols-2 gap-4 sm:gap-6">
110-
{eventsByYear[year].map((event: EventType) => (
111-
<EventCard key={event.title} event={event} />
110+
{eventsByYear[year].map((event: EventType, index: number) => (
111+
<EventCard key={`${event.link}${index}`} event={event} />
112112
))}
113113
</div>
114114
</div>

pwa/app/(common)/layout.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import "styles/common.css";
2+
import "@docsearch/css";
23
import { Poppins } from "next/font/google";
34
import Layout from "components/layout/Layout";
45
import { Metadata } from "next";

pwa/app/sitemap.ts

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
import editions, { currentEdition } from "data/con/editions";
2+
import { Locale, i18n } from "i18n/i18n-config";
3+
import { generateStaticParams as getScheduleEditions } from "app/con/[edition]/schedule/page";
4+
import { generateStaticParams as getSpeakersEditions } from "app/con/[edition]/speakers/page";
5+
import { getAllSpeakerSlugs } from "api/con/speakers";
6+
import { getAllConferenceSlugs } from "api/con/conferences";
7+
import { getAllEvents } from "api/events";
8+
import { getAllContributors } from "api/contributors";
9+
import { versions } from "consts";
10+
import { loadV2DocumentationNav } from "api/doc";
11+
12+
const basePath = process.env.NEXT_ROOT_URL?.startsWith("http")
13+
? process.env.NEXT_ROOT_URL
14+
: `https://${process.env.NEXT_ROOT_URL}`;
15+
16+
function createLocalePath(locale: Locale, path: string, edition?: string) {
17+
const baseLocalePath =
18+
i18n.defaultLocale === locale ? basePath : `${basePath}/${locale}`;
19+
return `${baseLocalePath}/${edition ? `${edition}/` : ""}${path}`;
20+
}
21+
22+
async function getAllConRoutes() {
23+
const routes: string[] = [];
24+
for (const locale of i18n.locales) {
25+
routes.push(createLocalePath(locale, "con"));
26+
routes.push(createLocalePath(locale, "con/editions"));
27+
28+
const editionsWithSchedules = await getScheduleEditions();
29+
const editionsWithSpeakers = await getSpeakersEditions();
30+
31+
for (const { edition } of editionsWithSchedules) {
32+
routes.push(createLocalePath(locale, `con/${edition}/schedule`));
33+
}
34+
for (const { edition } of editionsWithSpeakers) {
35+
routes.push(createLocalePath(locale, `con/${edition}/speakers`));
36+
}
37+
for (const { year: edition } of editions) {
38+
if (edition !== currentEdition)
39+
routes.push(createLocalePath(locale, `con/${edition}/review`));
40+
41+
const speakers = await getAllSpeakerSlugs(edition, locale);
42+
for (const speaker of speakers)
43+
routes.push(
44+
createLocalePath(locale, `con/${edition}/speakers/${speaker}`)
45+
);
46+
47+
const conferences = await getAllConferenceSlugs(edition, locale);
48+
for (const conference of conferences)
49+
routes.push(
50+
createLocalePath(locale, `con/${edition}/conferences/${conference}`)
51+
);
52+
53+
const legals = ["faq", "transparency", "code-of-conduct"]; // TODO: fix to put dynamic array after legal fix
54+
for (const legal of legals)
55+
routes.push(createLocalePath(locale, `con/${edition}/${legal}`));
56+
}
57+
}
58+
return routes;
59+
}
60+
61+
async function getAllStandardRoutes() {
62+
const routes: string[] = [];
63+
routes.push(`${basePath}/docs`);
64+
routes.push(`${basePath}/events`);
65+
routes.push(`${basePath}/references`);
66+
routes.push(`${basePath}/community`);
67+
routes.push(`${basePath}/community/contributors`);
68+
routes.push(`${basePath}/help`);
69+
routes.push(`${basePath}/404`);
70+
routes.push(`${basePath}/help/code-of-conduct`);
71+
routes.push(`${basePath}/resources/wallpapers`);
72+
routes.push(`${basePath}/resources/logos`);
73+
routes.push(`${basePath}/resources/colouring-webby`);
74+
routes.push(`${basePath}/trademark-policy`);
75+
76+
const events = await getAllEvents();
77+
for (const event of events) {
78+
routes.push(`${basePath}/events/${event.slug}`);
79+
}
80+
81+
const contributors = await getAllContributors();
82+
for (const contributor of contributors) {
83+
routes.push(`${basePath}/contributors/${contributor.login}`);
84+
}
85+
86+
for (const version of versions) {
87+
routes.push(`${basePath}/docs/v${version}`);
88+
const navs = await loadV2DocumentationNav(version);
89+
for (const nav of navs) {
90+
for (const link of nav.links) {
91+
routes.push(`${basePath}${link.link}`);
92+
}
93+
}
94+
}
95+
96+
return routes;
97+
}
98+
99+
export default async function sitemap() {
100+
const allLinks = [
101+
...(await getAllConRoutes()),
102+
...(await getAllStandardRoutes()),
103+
];
104+
return allLinks.map((path) => ({ url: path }));
105+
}

pwa/common.tailwind.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ module.exports = {
7979
borderRadius: {
8080
full: "100%",
8181
},
82+
boxShadow: {
83+
"inner-light": "inset 0 1px 0 0 #00555a",
84+
},
8285
rotate: {
8386
15: "15deg",
8487
30: "30deg",

pwa/components/docs/DocMenu.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ export default function DocMenu({
123123
autoOpen?: boolean;
124124
}) {
125125
const versionLinks = versions.map((v) => ({
126-
link: v === current ? "/docs" : `/docs/${v}/`,
126+
link: v === current ? "/docs" : `/docs/v${v}/distribution/`,
127127
title: v,
128128
}));
129129
return (

pwa/components/layout/Layout.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import "styles/common.css";
21
import Nav from "components/layout/Nav";
32
import Footer from "components/layout/Footer";
43
import localizedFormat from "dayjs/plugin/localizedFormat";

0 commit comments

Comments
 (0)