Skip to content

Commit 179e484

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

File tree

2 files changed

+28
-0
lines changed

2 files changed

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

0 commit comments

Comments
 (0)