Skip to content

Commit ef83645

Browse files
committed
Implement markdown page for auto-splitters documentation
1 parent 82dc35c commit ef83645

File tree

3 files changed

+45
-0
lines changed

3 files changed

+45
-0
lines changed

src/app/auto-splitters.tsx

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

src/router.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { AutoSplitters } from "./app/auto-splitters";
12
import { Converter } from "./app/converter";
23
import { Home } from "./app/home";
34
import { NotFound } from "./app/not-found";
@@ -11,6 +12,7 @@ export default function AppRouter() {
1112
<Route path="/converter" element={<Converter />} />
1213

1314
{/* Documentation Pages */}
15+
<Route path="/docs/auto-splitters.md" element={<AutoSplitters />} />
1416
<Route path="/docs/themes.md" element={<Themes />} />
1517

1618
{/* 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)