diff --git a/src/App.tsx b/src/App.tsx index ae8ad486..0533adf4 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,8 +1,15 @@ +import { useEffect, useState } from "react"; +import { Link, Route, Routes, useParams } from "react-router-dom"; import { ProjectListItem } from "@/components/ProjectListItem"; import { type ProjectEntry, projectList, projects } from "@/projects"; -import { Link, Route, Routes, useParams } from "react-router-dom"; import { ThemeToggle } from "./components/theme-toggle"; +const asciiFiles = [ + "cat-sleep.txt", + "polar-bear.txt", + "sleep-cat-ascii-art.txt", +]; + function App() { return ( @@ -17,16 +24,37 @@ export default App; function Home() { const isDevMode = import.meta.env.VITE_PUBLIC_DEV === "1"; + const [asciiArt, setAsciiArt] = useState(""); + const [asciiFile] = useState( + () => asciiFiles[Math.floor(Math.random() * asciiFiles.length)], + ); const sortedProjects: ProjectEntry[] = [...projectList].sort( (a, b) => parseDate(b.metadata.date).getTime() - parseDate(a.metadata.date).getTime(), ); + useEffect(() => { + let isActive = true; + fetch(`/ascii/${asciiFile}`) + .then((response) => response.text()) + .then((text) => { + if (isActive) setAsciiArt(text); + }); + return () => { + isActive = false; + }; + }, [asciiFile]); + return (
-

Oliver Bryan

+ {/* {asciiArt ? ( +
+						{asciiArt}
+					
+ ) : null} */} +

Oliver Bryan

{sortedProjects.map((project) => (