Skip to content

Commit 1bdeb71

Browse files
authored
Add page generation for documentation (#25)
1 parent ae5c45c commit 1bdeb71

File tree

13 files changed

+149
-57
lines changed

13 files changed

+149
-57
lines changed

package-lock.json

Lines changed: 29 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"@radix-ui/react-dropdown-menu": "^2.1.16",
1616
"@radix-ui/react-navigation-menu": "^1.2.14",
1717
"@radix-ui/react-slot": "^1.2.3",
18+
"@tanstack/react-query": "^5.90.12",
1819
"class-variance-authority": "^0.7.1",
1920
"clsx": "^2.1.1",
2021
"lucide-react": "^0.548.0",

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 { AppGitHubGenericMarkdown } from "@/components/libresplit/AppGitHubGenericMarkdown";
2+
3+
export function AutoSplitters() {
4+
return (
5+
<div>
6+
<AppGitHubGenericMarkdown url="https://raw.githubusercontent.com/LibreSplit/LibreSplit/refs/heads/main/docs/auto-splitters.md" />
7+
</div>
8+
);
9+
}

src/app/home.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { AppGitHubReadme } from "@/components/libresplit/AppGitHubReadme";
1+
import { AppGitHubGenericMarkdown } from "@/components/libresplit/AppGitHubGenericMarkdown";
22
import { AppHero } from "@/components/libresplit/AppHero";
33

44
export function Home() {
55
return (
66
<div className="flex flex-col items-center justify-center">
77
<AppHero />
8-
<AppGitHubReadme />
8+
<AppGitHubGenericMarkdown url="https://raw.githubusercontent.com/LibreSplit/LibreSplit/refs/heads/main/README.md" />
99
</div>
1010
);
1111
}

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 { AppGitHubGenericMarkdown } from "@/components/libresplit/AppGitHubGenericMarkdown";
2+
3+
export function SettingsKeybinds() {
4+
return (
5+
<div>
6+
<AppGitHubGenericMarkdown url="https://raw.githubusercontent.com/LibreSplit/LibreSplit/refs/heads/main/docs/settings-keybinds.md" />
7+
</div>
8+
);
9+
}

src/app/split-files.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { AppGitHubGenericMarkdown } from "@/components/libresplit/AppGitHubGenericMarkdown";
2+
3+
export function SplitFiles() {
4+
return (
5+
<div>
6+
<AppGitHubGenericMarkdown url="https://raw.githubusercontent.com/LibreSplit/LibreSplit/refs/heads/main/docs/settings-keybinds.md" />
7+
</div>
8+
);
9+
}

src/app/themes.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { AppGitHubGenericMarkdown } from "@/components/libresplit/AppGitHubGenericMarkdown";
2+
3+
export function Themes() {
4+
return (
5+
<div>
6+
<AppGitHubGenericMarkdown url="https://raw.githubusercontent.com/LibreSplit/LibreSplit/refs/heads/main/docs/themes.md" />
7+
</div>
8+
);
9+
}

src/app/troubleshooting.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { AppGitHubGenericMarkdown } from "@/components/libresplit/AppGitHubGenericMarkdown";
2+
3+
export function Troubleshooting() {
4+
return (
5+
<div>
6+
<AppGitHubGenericMarkdown url="https://raw.githubusercontent.com/LibreSplit/LibreSplit/refs/heads/main/docs/troubleshooting.md" />
7+
</div>
8+
);
9+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { AppLoading } from "./AppLoading";
2+
import { Markdown } from "@/lib/markdown";
3+
import { useQuery } from "@tanstack/react-query";
4+
5+
async function fetchMarkdown(url: string): Promise<string> {
6+
const res = await fetch(url);
7+
8+
if (!res.ok) {
9+
throw new Error("Failed to fetch markdown from GitHub.");
10+
}
11+
12+
return res.text();
13+
}
14+
15+
type AppGitHubGenericMarkdownProps = {
16+
url: string;
17+
};
18+
19+
export function AppGitHubGenericMarkdown({
20+
url,
21+
}: AppGitHubGenericMarkdownProps) {
22+
const { data, isLoading, error } = useQuery({
23+
queryKey: ["markdown-text"],
24+
queryFn: () => fetchMarkdown(url),
25+
enabled: !!url,
26+
});
27+
28+
if (isLoading) return <AppLoading />;
29+
if (error) return <div>Failed to fetch markdown from GitHub.</div>;
30+
if (!data) return <div>Failed to fetch markdown from GitHub.</div>;
31+
32+
return (
33+
<div>
34+
<Markdown content={data} />
35+
</div>
36+
);
37+
}

src/components/libresplit/AppGitHubReadme.tsx

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
 (0)