From 73a2852ee3a8079900cb5e9f22feff8afe907423 Mon Sep 17 00:00:00 2001 From: John O'Keefe Date: Thu, 6 Aug 2026 09:51:04 -0400 Subject: [PATCH] fix(reader): back button remembers the page you came from The reader's back button was hardcoded to the book detail page (/media/{id}), so even when you launched the reader straight from the dashboard the back button ignored that and sent you to the detail view. Mirror the existing book-detail.ts referrer pattern: capture document.referrer into sessionStorage on load (excluding other reader pages and the reader's own URL), then override the back link's click to navigate there. Falls back to the link's original href (/media/{id}) when no valid referrer exists (direct URL access). --- templates/reader.templ | 2 +- templates/reader_templ.go | 4 ++-- web/src/reader/reader.ts | 28 ++++++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/templates/reader.templ b/templates/reader.templ index bfcd1c7..75c8dc1 100644 --- a/templates/reader.templ +++ b/templates/reader.templ @@ -84,7 +84,7 @@ templ ReaderChrome(user User, metadata ReaderMetadata, progress ReadingProgress)