|
1 | 1 | import { useEffect, useState } from 'react' |
2 | 2 | import { Link, Outlet, useLocation, useNavigate } from 'react-router-dom' |
3 | 3 | import siteContent from './siteContent.json' |
| 4 | +import { githubConfig } from './generated/githubData' |
4 | 5 |
|
5 | 6 | type Theme = 'dark' | 'light' |
6 | 7 |
|
@@ -37,6 +38,52 @@ function App() { |
37 | 38 | window.localStorage.setItem('gitforge-theme', theme) |
38 | 39 | }, [theme]) |
39 | 40 |
|
| 41 | + // Apply font family from generated GitHub config |
| 42 | + useEffect(() => { |
| 43 | + const font = (githubConfig as { |
| 44 | + fontFamily?: 'system' | 'ubuntu' | 'comic-sans' | 'inter' | 'roboto' |
| 45 | + }).fontFamily || 'system' |
| 46 | + let value = |
| 47 | + "system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif" |
| 48 | + if (font === 'ubuntu') { |
| 49 | + value = "'Ubuntu', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif" |
| 50 | + // Inject Google Fonts stylesheet for Ubuntu if not already present |
| 51 | + if (!document.getElementById('gf-font-ubuntu')) { |
| 52 | + const link = document.createElement('link') |
| 53 | + link.id = 'gf-font-ubuntu' |
| 54 | + link.rel = 'stylesheet' |
| 55 | + link.href = |
| 56 | + 'https://fonts.googleapis.com/css2?family=Ubuntu:wght@400;500;700&display=swap' |
| 57 | + document.head.appendChild(link) |
| 58 | + } |
| 59 | + } else if (font === 'inter') { |
| 60 | + value = |
| 61 | + "'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif" |
| 62 | + if (!document.getElementById('gf-font-inter')) { |
| 63 | + const link = document.createElement('link') |
| 64 | + link.id = 'gf-font-inter' |
| 65 | + link.rel = 'stylesheet' |
| 66 | + link.href = |
| 67 | + 'https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap' |
| 68 | + document.head.appendChild(link) |
| 69 | + } |
| 70 | + } else if (font === 'roboto') { |
| 71 | + value = |
| 72 | + "'Roboto', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif" |
| 73 | + if (!document.getElementById('gf-font-roboto')) { |
| 74 | + const link = document.createElement('link') |
| 75 | + link.id = 'gf-font-roboto' |
| 76 | + link.rel = 'stylesheet' |
| 77 | + link.href = |
| 78 | + 'https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap' |
| 79 | + document.head.appendChild(link) |
| 80 | + } |
| 81 | + } else if (font === 'comic-sans') { |
| 82 | + value = "'Comic Sans MS', 'Comic Sans', cursive" |
| 83 | + } |
| 84 | + document.documentElement.style.setProperty('--gf-font-family', value) |
| 85 | + }, []) |
| 86 | + |
40 | 87 | // GitHub Pages 404 redirect: ?/path -> /path |
41 | 88 | useEffect(() => { |
42 | 89 | const q = location.search |
@@ -75,7 +122,7 @@ function App() { |
75 | 122 | }, [hero.title]) |
76 | 123 |
|
77 | 124 | const rootClasses = |
78 | | - 'min-h-screen font-sans bg-slate-50 text-slate-900 dark:bg-[#050509] dark:text-slate-50' |
| 125 | + 'min-h-screen bg-slate-50 text-slate-900 dark:bg-[#050509] dark:text-slate-50' |
79 | 126 | const headerClasses = |
80 | 127 | theme === 'dark' |
81 | 128 | ? 'sticky top-0 z-20 border-b border-white/5 bg-[#050509]/90 backdrop-blur' |
|
0 commit comments