Skip to content

Commit e8c84bf

Browse files
committed
Pull markdown from GitHub.
1 parent 4a94ea2 commit e8c84bf

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

src/app/home.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
import { AppGitHubReadme } from "@/components/libresplit/AppGitHubReadme";
2+
13
export function Home() {
24
return (
35
<div>
46
<h1>LibreSplit</h1>
7+
<AppGitHubReadme />
58
</div>
69
);
710
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { useEffect, useState } from "react";
2+
3+
export function AppGitHubReadme() {
4+
const [readme, setReadme] = useState<string>("Loading...");
5+
6+
const urlReadme =
7+
"https://raw.githubusercontent.com/LibreSplit/LibreSplit/refs/heads/main/README.md";
8+
9+
// Fetch markdown from GitHub page for LibreSplit, place into the readme state.
10+
useEffect(() => {
11+
fetch(urlReadme)
12+
.then((res) => {
13+
// Check for HTTP error.
14+
if (!res.ok) throw new Error("HTTP Error! Status: ${res.status}");
15+
return res.text();
16+
})
17+
.then((text) => setReadme(text))
18+
.catch(() => {
19+
setReadme("Failed to load README from GitHub.");
20+
});
21+
}, []);
22+
23+
return (
24+
<div>
25+
<p>{readme}</p>
26+
</div>
27+
);
28+
}

0 commit comments

Comments
 (0)