Skip to content

Commit 44da4f9

Browse files
committed
Implement markdown page for settings and keybinds
1 parent ef83645 commit 44da4f9

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed

src/app/settings-keybinds.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { AppGitHubSettingsKeybinds } from "@/components/libresplit/AppGitHubSettingsKeybinds";
2+
3+
export function SettingsKeybinds() {
4+
return (
5+
<div>
6+
<AppGitHubSettingsKeybinds />
7+
</div>
8+
);
9+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { useEffect, useState } from "react";
2+
3+
import { AppLoading } from "./AppLoading";
4+
import { Markdown } from "@/lib/markdown";
5+
6+
export function AppGitHubSettingsKeybinds() {
7+
const [settingsKeybinds, setSettingsKeybinds] =
8+
useState<string>("Loading...");
9+
const [isLoading, setIsLoading] = useState(true);
10+
11+
const urlSettingsKeybinds =
12+
"https://raw.githubusercontent.com/LibreSplit/LibreSplit/refs/heads/main/docs/settings-keybinds.md";
13+
14+
// Fetch markdown from GitHub page for LibreSplit, place into the readme state.
15+
useEffect(() => {
16+
fetch(urlSettingsKeybinds)
17+
.then((res) => {
18+
if (!res.ok) throw new Error(`HTTP Error! Status: ${res.status}`);
19+
return res.text();
20+
})
21+
.then((text) => setSettingsKeybinds(text))
22+
.catch(() => setSettingsKeybinds("Failed to load README from GitHub."))
23+
.finally(() => setIsLoading(false));
24+
}, []);
25+
26+
if (isLoading) {
27+
return <AppLoading />;
28+
}
29+
30+
return (
31+
<div>
32+
<Markdown content={settingsKeybinds} />
33+
</div>
34+
);
35+
}

src/router.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { AutoSplitters } from "./app/auto-splitters";
22
import { Converter } from "./app/converter";
33
import { Home } from "./app/home";
44
import { NotFound } from "./app/not-found";
5+
import { SettingsKeybinds } from "./app/settings-keybinds";
56
import { Themes } from "./app/themes";
67
import { Route, Routes } from "react-router";
78

@@ -13,6 +14,7 @@ export default function AppRouter() {
1314

1415
{/* Documentation Pages */}
1516
<Route path="/docs/auto-splitters.md" element={<AutoSplitters />} />
17+
<Route path="/docs/settings-keybinds.md" element={<SettingsKeybinds />} />
1618
<Route path="/docs/themes.md" element={<Themes />} />
1719

1820
{/* Fall back on app's 404 page. This is because of the SPA routing trick with 404.html used in GitHub Pages. */}

0 commit comments

Comments
 (0)