File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed
Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change 1+ import { AppGitHubReadme } from "@/components/libresplit/AppGitHubReadme" ;
2+
13export function Home ( ) {
24 return (
35 < div >
46 < h1 > LibreSplit</ h1 >
7+ < AppGitHubReadme />
58 </ div >
69 ) ;
710}
Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments