import "@/styles/globals.css"; import { Suspense } from "react"; import { fetchWordsByToneAndSyllables } from "@/actions/tones"; import ToneSelectorClient from "@/components/tones/ToneSelectorClient"; import { Skeleton } from "@/components/ui/skeleton"; // For Suspense fallback import { thaiTones } from "@/lib/types/phonetics"; import { randomFromArray } from "@/lib/utils"; export const getConfig = async () => { return { render: "static", // Or 'dynamic' if you prefer SSR for every request }; }; async function randomTones(tries = 0) { const syllables = Math.floor(Math.random() * 5); const toneStrings = Object.values(thaiTones); const tones = Array.from(Array(syllables)).map((_) => randomFromArray(toneStrings), ); console.log({ tones, toneStrings }); const initialWords = await fetchWordsByToneAndSyllables(tones); if (!initialWords || initialWords.length === 0) return randomTones(tries + 1); else return { initialWords, tones }; } // Function to fetch the initial word on the server async function InitialWordLoader() { // Fetch a random 1-syllable Thai word with any tone initially const { initialWords, tones } = await randomTones(); return ; } // Loading fallback component function TonePageSkeleton() { return (
); } export default function TonesPage() { return (
}>
); } export const metadata = { title: "Thai Tone Explorer", description: "Explore Thai words by syllable count and tones.", };