v2.1: stylistic updates & countdown timer

This commit is contained in:
George Powell
2025-12-21 18:24:38 -05:00
parent 0d50ff5f27
commit 5999221b8f
14 changed files with 274 additions and 22 deletions

View File

@@ -9,13 +9,16 @@ import type { DailyVerse } from '$lib/server/db/schema';
import crypto from 'node:crypto';
async function getTodayVerse(): Promise<DailyVerse> {
// Get the current date (server-side)
const dateStr = new Date().toLocaleDateString('en-CA', { timeZone: 'America/New_York' });
// If there's an existing verse for the current date, return it
const existing = await db.select().from(dailyVerses).where(eq(dailyVerses.date, dateStr)).limit(1);
if (existing.length > 0) {
return existing[0];
}
// Otherwise get a new random verse
const apiVerse = await fetchRandomVerse();
const createdAt = sql`${Math.floor(Date.now() / 1000)}`;