Fix remaining issues: page title and browser navigation
- Page title now dynamically updates: 'NKJV Bible', 'ESV Bible', or 'The Bible' - Browser back button detection improved - URL parameters are read on navigation changes - Clearing version selection when returning to home without version parameter - Complete NKJV logo update committed to repository UI now properly reflects selected version in both title and navigation behaviors
This commit is contained in:
@@ -34,14 +34,18 @@ function App() {
|
||||
// Debug logging
|
||||
console.log('App component rendered');
|
||||
|
||||
// Read version from URL on mount
|
||||
// Read version from URL on mount and when location changes
|
||||
useEffect(() => {
|
||||
const urlParams = new URLSearchParams(location.search);
|
||||
const versionParam = urlParams.get('version');
|
||||
if (versionParam && (versionParam === 'esv' || versionParam === 'nkjv')) {
|
||||
setSelectedVersion(versionParam);
|
||||
} else if (!versionParam && selectedVersion && location.pathname === '/') {
|
||||
// If we're back at home without version param and had a version selected,
|
||||
// this likely means user hit back and should see version selector
|
||||
setSelectedVersion('');
|
||||
}
|
||||
}, []);
|
||||
}, [location.search, selectedVersion]);
|
||||
|
||||
useEffect(() => {
|
||||
console.log('App useEffect triggered');
|
||||
@@ -61,6 +65,10 @@ function App() {
|
||||
url.searchParams.delete('version');
|
||||
}
|
||||
window.history.replaceState({}, '', url.toString());
|
||||
|
||||
// Update page title to reflect selected version
|
||||
const versionTitle = selectedVersion ? selectedVersion.toUpperCase() : '';
|
||||
document.title = versionTitle ? `${versionTitle} Bible` : 'The Bible';
|
||||
}, [selectedVersion]);
|
||||
|
||||
// Load user preferences when user changes
|
||||
|
||||
Reference in New Issue
Block a user