Files
biblical-guide.com/app/[locale]/bible/page.tsx
Andrei 44831a096f fix: improve Bible reader loading UX with skeleton states
- Remove full-screen loading backdrop that hides entire UI
- Add skeleton loading components for chapter headers and verses
- Implement smooth content transitions without UI disappearance
- Change initial loading state to prevent immediate UI hide
- Enhance Suspense fallbacks with better loading messages
- Keep Bible reader interface visible during all loading states

Fixes issue where:
- Entire reader disappeared during chapter changes
- Users saw only header/footer during loading
- Poor perceived performance with jarring transitions

Now provides professional skeleton loading within the reader
interface for a smooth, responsive user experience.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-29 20:14:51 +00:00

66 lines
1.6 KiB
TypeScript

import { Suspense } from 'react'
import { redirect } from 'next/navigation'
import BibleReader from './reader'
import { prisma } from '@/lib/db'
interface PageProps {
searchParams: Promise<{
version?: string
book?: string
chapter?: string
verse?: string
}>
params: Promise<{
locale: string
}>
}
// Helper function to convert UUIDs to SEO-friendly slugs
async function convertToSeoUrl(versionId: string, bookId: string, chapter: string, locale: string) {
try {
const version = await prisma.bibleVersion.findUnique({
where: { id: versionId }
})
const book = await prisma.bibleBook.findUnique({
where: { id: bookId }
})
if (version && book) {
const versionSlug = version.abbreviation.toLowerCase()
const bookSlug = book.bookKey.toLowerCase()
return `/${locale}/bible/${versionSlug}/${bookSlug}/${chapter}`
}
} catch (error) {
console.error('Error converting to SEO URL:', error)
}
return null
}
export default async function BiblePage({ searchParams, params }: PageProps) {
const { version, book, chapter } = await searchParams
const { locale } = await params
// If we have the old URL format with UUIDs, redirect to SEO-friendly URL
if (version && book && chapter) {
const seoUrl = await convertToSeoUrl(version, book, chapter, locale)
if (seoUrl) {
redirect(seoUrl)
}
}
return (
<Suspense fallback={
<div style={{
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
minHeight: '200px'
}}>
Loading Bible reader...
</div>
}>
<BibleReader />
</Suspense>
)
}