dev experience

This commit is contained in:
2026-01-01 17:43:38 +01:00
parent df7e5db5ba
commit 9958053462
8 changed files with 208 additions and 173 deletions

View File

@@ -64,7 +64,17 @@ export function isAlpha(): boolean {
*/
export function getPublicRoutes(): readonly string[] {
return [
// Core public pages
'/',
// Public content routes (leagues, drivers, teams, leaderboards, races)
'/leagues',
'/drivers',
'/teams',
'/leaderboards',
'/races',
// Auth routes
'/api/signup',
'/api/auth/signup',
'/api/auth/login',
@@ -85,8 +95,27 @@ export function getPublicRoutes(): readonly string[] {
/**
* Check if a route is public (accessible in all modes)
* Supports both exact matches and prefix matches for nested routes
*/
export function isPublicRoute(pathname: string): boolean {
const publicRoutes = getPublicRoutes();
return publicRoutes.includes(pathname);
// Check exact match first
if (publicRoutes.includes(pathname)) {
return true;
}
// Check prefix matches for nested routes
// e.g., '/leagues' should match '/leagues/123', '/leagues/create', etc.
const publicPrefixes = [
'/leagues',
'/drivers',
'/teams',
'/leaderboards',
'/races',
];
return publicPrefixes.some(prefix =>
pathname === prefix || pathname.startsWith(prefix + '/')
);
}