diff --git a/app/page.tsx b/app/page.tsx index bcfb4a7..846f4fe 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -3,8 +3,23 @@ import { ArrowRight, Search, Star, Sparkles, Zap, Shield, Heart } from 'lucide-r import { getStats } from '@/lib/db' import { AwesomeIcon } from '@/components/ui/awesome-icon' +// Make this page dynamic to avoid pre-rendering during build +export const dynamic = 'force-dynamic' +export const revalidate = 0 + export default function Home() { - const stats = getStats() + // Provide fallback stats if database doesn't exist (e.g., during Docker build) + let stats = { totalLists: 100, totalRepositories: 10000, totalReadmes: 10000, lastUpdated: null } + + // Try to get real stats from database, fall back to defaults if not available + try { + stats = getStats() + } catch (error) { + // Database not available (e.g., during build) - use fallback stats + if (process.env.NODE_ENV !== 'production') { + console.warn('Database not available, using fallback stats') + } + } return (
{/* Hero Section */} diff --git a/lib/db.ts b/lib/db.ts index b09e181..7c113d6 100644 --- a/lib/db.ts +++ b/lib/db.ts @@ -1,5 +1,6 @@ import Database from 'better-sqlite3' import { join } from 'path' +import { existsSync } from 'fs' // Database path - using user's .awesome directory const DB_PATH = process.env.AWESOME_DB_PATH || join(process.env.HOME || '', '.awesome', 'awesome.db') @@ -8,6 +9,10 @@ let db: Database.Database | null = null export function getDb(): Database.Database { if (!db) { + // Check if database file exists before trying to open it + if (!existsSync(DB_PATH)) { + throw new Error(`Database file not found at ${DB_PATH}`) + } db = new Database(DB_PATH, { readonly: true }) // Enable WAL mode for better concurrency db.pragma('journal_mode = WAL')