- Add dynamic route structure /[locale]/bible/[version]/[book]/[chapter] - Convert UUID-based URLs to readable format (e.g., /en/bible/eng-kjv/genesis/1) - Implement automatic redirects from old URLs to new SEO-friendly format - Add SEO metadata generation with proper titles, descriptions, and OpenGraph tags - Create API endpoint for URL conversion between formats - Update navigation in search results, bookmarks, and internal links - Fix PWA manifest icons to correct dimensions (192x192, 512x512) - Resolve JavaScript parameter passing issues between server and client components - Maintain backward compatibility with existing bookmark and search functionality Benefits: - Improved SEO with descriptive URLs - Better user experience with readable URLs - Enhanced social media sharing - Maintained full backward compatibility
57 lines
1.5 KiB
TypeScript
57 lines
1.5 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>Loading...</div>}>
|
|
<BibleReader />
|
|
</Suspense>
|
|
)
|
|
} |