Fix post detail page navigation issues
- Updated back button to use JavaScript function instead of direct href - Added URL parameter preservation when navigating back to feed - Improved fallback logic to handle browser history properly 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
<main class="main-content single-post">
|
||||
<!-- Back Button -->
|
||||
<div class="back-section">
|
||||
<a href="{{ url_for('index') }}" class="back-btn">← Back to Feed</a>
|
||||
<a href="#" onclick="goBackToFeed(event)" class="back-btn">← Back to Feed</a>
|
||||
</div>
|
||||
|
||||
<!-- Post Content -->
|
||||
@@ -657,13 +657,23 @@
|
||||
</style>
|
||||
|
||||
<script>
|
||||
function goBackToFeed() {
|
||||
function goBackToFeed(event) {
|
||||
event.preventDefault();
|
||||
|
||||
// Try to go back in browser history first
|
||||
if (window.history.length > 1 && document.referrer && document.referrer.includes(window.location.origin)) {
|
||||
window.history.back();
|
||||
} else {
|
||||
// Fallback to dashboard - use the proper URL
|
||||
window.location.href = {{ url_for('index')|tojson }};
|
||||
// Fallback to dashboard - construct URL with current query parameters
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
const baseUrl = {{ url_for('index')|tojson }};
|
||||
|
||||
// Add query parameters if they exist
|
||||
if (urlParams.toString()) {
|
||||
window.location.href = baseUrl + '?' + urlParams.toString();
|
||||
} else {
|
||||
window.location.href = baseUrl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user