Download code/web/src/App.tsx from MiniMaxAI/oss-ecosystem-data: direct link, hf CLI and curl.
- Browser
- Download file 1.12 kB
-
https://huggingface.co/datasets/MiniMaxAI/oss-ecosystem-data/resolve/0619e492f9bc7da684ed07f740bb2ebdbee5c568/code/web/src/App.tsx
- Command line
-
hf download hf://datasets/MiniMaxAI/oss-ecosystem-data@0619e492f9bc7da684ed07f740bb2ebdbee5c568/code/web/src/App.tsx
-
curl -L -o App.tsx https://huggingface.co/datasets/MiniMaxAI/oss-ecosystem-data/resolve/0619e492f9bc7da684ed07f740bb2ebdbee5c568/code/web/src/App.tsx
1.12 kB
| import { Fragment, useEffect, useState } from "react" | |
| import type { Site } from "@/lib/types" | |
| import { useRoute } from "@/lib/route" | |
| import { T, useLang } from "@/lib/i18n" | |
| import { Home } from "@/pages/home" | |
| import { CategoryPage } from "@/pages/category" | |
| export default function App() { | |
| const [site, setSite] = useState<Site | null>(null) | |
| const [failed, setFailed] = useState(false) | |
| const route = useRoute() | |
| const lang = useLang() | |
| useEffect(() => { | |
| fetch("data/site.json") | |
| .then((r) => (r.ok ? r.json() : Promise.reject(r.status))) | |
| .then(setSite) | |
| .catch(() => setFailed(true)) | |
| }, []) | |
| useEffect(() => { | |
| if (!route.cat) document.title = T.site | |
| }, [route.cat, lang]) | |
| if (failed) return <p className="p-10 text-lg">{T.noData}</p> | |
| if (!site) return <div className="dark stage min-h-screen" /> | |
| // A new language draws the page afresh, so nothing keeps copy from the old one. | |
| return ( | |
| <Fragment key={lang}> | |
| {route.cat | |
| ? <CategoryPage key={route.cat} site={site} cat={route.cat} rel={route.rel} /> | |
| : <Home site={site} />} | |
| </Fragment> | |
| ) | |
| } | |