import { useState, useEffect } from 'react' import styles from './TerminalHeader.module.css' import { PROJECT_NAME, REPO_NAME, LINKS, AUTHORS } from '../config' function useGitHubProfile(username) { const [profile, setProfile] = useState(null) const [loading, setLoading] = useState(true) useEffect(() => { const cacheKey = 'gh-profile-' + username // Check sessionStorage first — avoids hammering the API on every render try { const cached = sessionStorage.getItem(cacheKey) if (cached) { setProfile(JSON.parse(cached)) setLoading(false) return } } catch (e) {} fetch('https://api.github.com/users/' + username) .then(r => { if (!r.ok) throw new Error('HTTP ' + r.status) return r.json() }) .then(d => { // Don't cache error responses like rate limit messages if (!d.message) { try { sessionStorage.setItem(cacheKey, JSON.stringify(d)) } catch (e) {} } setProfile(d) setLoading(false) }) .catch(() => setLoading(false)) }, [username]) return { profile, loading } } function AuthorTile({ username, active }) { const { profile, loading } = useGitHubProfile(username) const tileClass = styles.authorTile + (active ? ' ' + styles.authorTileActive : '') if (loading) { return (