From 0a6d35a97eb4afaeabca3a460686e08887a162a8 Mon Sep 17 00:00:00 2001 From: Hugo Montenegro Date: Sun, 15 Mar 2026 21:52:38 +0000 Subject: [PATCH 1/2] fix: definition/image for diacritic words, reveal today's word after winning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Three fixes: 1. Definition & image endpoints rejected valid words with diacritics (e.g. Portuguese "farão") due to unicode normalization mismatch. Now tries both NFC and NFD forms when validating against word list. 2. Word archive now reveals today's word after the game is over. Checks localStorage for game_over state client-side and shows the word with green tiles instead of question marks. 3. Word archive marks completed past words with a checkmark. Reads game_results from localStorage and maps dates to day indices to show which words the player has already played. --- pages/[lang]/words.vue | 76 +++++++++++++++++++++- server/api/[lang]/definition/[word].get.ts | 7 +- server/api/[lang]/word-image/[word].get.ts | 2 +- 3 files changed, 78 insertions(+), 7 deletions(-) diff --git a/pages/[lang]/words.vue b/pages/[lang]/words.vue index 0de5a5e0..665f849e 100644 --- a/pages/[lang]/words.vue +++ b/pages/[lang]/words.vue @@ -146,6 +146,44 @@ function formatDate(dateStr: string): string { function winRate(stats: { total: number; wins: number }): number { return Math.round((stats.wins / stats.total) * 100); } + +// Client-side: reveal today's word if game is over (won or lost) +const todayRevealed = ref(null); +const completedDays = ref(new Set()); + +onMounted(() => { + try { + // Check current game state — key is the language code + const saved = localStorage.getItem(lang); + if (saved) { + const state = JSON.parse(saved); + if (state.game_over && state.todays_word) { + todayRevealed.value = state.todays_word; + } + } + + // Build set of completed day indices from game_results + const results = localStorage.getItem('game_results'); + if (results) { + const parsed = JSON.parse(results); + const langResults = parsed[lang]; + if (Array.isArray(langResults)) { + // game_results stores [{won, attempts, date}, ...] + // We need to map dates to day indices + for (const r of langResults) { + if (r.date) { + const d = new Date(r.date); + const nDays = Math.floor(d.getTime() / 86400000); + const idx = nDays - 18992 + 195; + completedDays.value.add(idx); + } + } + } + } + } catch { + // localStorage unavailable + } +});