Skip to content

Commit b997d8d

Browse files
committed
docusaurus can't stop me, im a magician
1 parent 1037c4b commit b997d8d

File tree

3 files changed

+21
-10
lines changed

3 files changed

+21
-10
lines changed

frontend/docusaurus.config.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,14 @@ const config: Config = {
6666
async function serverRoutesPlugin(context, options) {
6767
return {
6868
name: "server-routes-plugin",
69-
async contentLoaded({ content, actions }) {
70-
const { createData, addRoute } = actions;
69+
async contentLoaded({ actions }) {
70+
const { addRoute } = actions;
7171

7272
// Add the dynamic route
7373
addRoute({
74-
path: "/servers/:ip",
75-
component: "@site/src/pages/servers/[ip].tsx",
76-
exact: true,
74+
path: "/servers/",
75+
component: "@site/src/pages/servers/index.tsx",
76+
exact: false,
7777
});
7878
},
7979
};
@@ -195,7 +195,7 @@ const config: Config = {
195195
label: "Docs",
196196
},
197197
{ to: "/blog", label: "Blog", position: "right" },
198-
{ href: "https://forum.open.mp/", label: "Forums", position: "right" },
198+
{ to: "https://forum.open.mp/", label: "Forums", position: "right" },
199199
{ to: "/servers", label: "Servers", position: "right" },
200200
{ to: "/partners", label: "Partners", position: "right" },
201201
{

frontend/src/pages/servers/[ip].tsx renamed to frontend/src/components/ServerInfoPage.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,7 @@ const Content = ({ ip }: { ip: string }) => {
138138
return <Info data={data} />;
139139
};
140140

141-
const Page = () => {
142-
const { ip } = useParams<{ ip: string }>();
141+
const ServerInfoPage = ({ ip }: { ip: string }) => {
143142
if (!ip) {
144143
return <LoadingBanner />;
145144
}
@@ -156,7 +155,7 @@ const Page = () => {
156155
);
157156
};
158157

159-
export default Page;
158+
export default ServerInfoPage;
160159

161160
const formatDistance = (
162161
date: Date | string | number,

frontend/src/pages/servers/index.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@ import React, {
55
ReactNode,
66
useEffect,
77
useMemo,
8-
useState
8+
useState,
99
} from "react";
1010
import { FixedSizeList } from "react-window";
1111
import LoadingBanner from "../../components/LoadingBanner";
1212
import ServerRow from "../../components/ServerRow";
1313
import { showToast, ToastContainer } from "../../components/Toast";
1414
import { API_ADDRESS } from "../../constants";
1515
import { CoreServerData, ServerAllData } from "../../types";
16+
import ServerInfoPage from "../../components/ServerInfoPage";
1617

1718
const API_SERVERS = `${API_ADDRESS}/servers/`;
1819

@@ -331,6 +332,17 @@ const List = ({ data }: { data: CoreServerData[] }) => {
331332
};
332333

333334
const Page = (): ReactNode => {
335+
if (
336+
typeof window !== "undefined" &&
337+
window.location &&
338+
window.location.pathname &&
339+
window.location.pathname.includes(":")
340+
) {
341+
const path = window.location.pathname;
342+
const server = path.split("/servers/")[1];
343+
return <ServerInfoPage ip={server} />;
344+
}
345+
334346
const [loading, setLoading] = useState<boolean>(true);
335347
const [data, setData] = useState<CoreServerData[]>([]);
336348

0 commit comments

Comments
 (0)