| 21 | const [version, setVersion] = useState(""); |
| 22 | useEffect(() => { |
| 23 | async function fetchVersion() { |
| 24 | try { |
| 25 | const res = await fetch( |
| 26 | "https://raw.githubusercontent.com/CodeGraphContext/CodeGraphContext/main/README.md" |
| 27 | ); |
| 28 | if (!res.ok) throw new Error("Failed to fetch README"); |
| 29 | |
| 30 | const text = await res.text(); |
| 31 | const match = text.match( |
| 32 | /\*\*Version:\*\*\s*([0-9]+\.[0-9]+\.[0-9]+)/i |
| 33 | ); |
| 34 | setVersion(match ? match[1] : "N/A"); |
| 35 | } catch (err) { |
| 36 | console.error(err); |
| 37 | setVersion("N/A"); |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | fetchVersion(); |
| 42 | }, []); |