Skip to content

Commit 82dc35c

Browse files
committed
Implement markdown page for themes documentation
1 parent 0e67330 commit 82dc35c

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed

src/app/themes.tsx

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

src/router.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Converter } from "./app/converter";
22
import { Home } from "./app/home";
33
import { NotFound } from "./app/not-found";
4+
import { Themes } from "./app/themes";
45
import { Route, Routes } from "react-router";
56

67
export default function AppRouter() {
@@ -9,6 +10,9 @@ export default function AppRouter() {
910
<Route path="/" element={<Home />} />
1011
<Route path="/converter" element={<Converter />} />
1112

13+
{/* Documentation Pages */}
14+
<Route path="/docs/themes.md" element={<Themes />} />
15+
1216
{/* Fall back on app's 404 page. This is because of the SPA routing trick with 404.html used in GitHub Pages. */}
1317
<Route path="*" element={<NotFound />} />
1418
</Routes>

0 commit comments

Comments
 (0)