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:
chelsea
2025-10-12 15:16:38 -05:00
parent 301c2b33f0
commit b438762758

View File

@@ -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;
}
}
}