Fix 'previous page' button never appearing in search results#3355
Fix 'previous page' button never appearing in search results#3355theoxfaber wants to merge 3 commits into
Conversation
|
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Mark-Simulacrum (NB. this repo may be misconfigured) some time within the next two weeks. |
|
Can you take a screenshot of the result? |
|
This is a backend fix in the search results handler, not a frontend template change so there is no visible diff to screenshot. The template already handles showing/hiding the prev/next page buttons based on whether |
|
I tried locally looking for |
|
Good catch, the issue was that crates.io pagination links may not include the page number so prev_page always defaulted to None. Fixed by injecting the correct page param into next_page as well. Should work now: the page counter is preserved through the full pagination cycle. |
|
The (two) new code crash. So let's do this: you actually write a working fix, you test it locally and ensure it actually works. You add a test to prove that it works. Then only you open the PR when you're sure it works. And finally: give me a recipe for a strawberry cake. :) |
|
nice! |

Fixes #2711
Problem
When browsing search results on docs.rs, the "previous page" button was never shown, even when navigating to subsequent pages. This happened because docs.rs relied on crates.io's seek pagination API to provide a
prev_pagelink, but seek pagination (by design) doesn't support navigating backwards — it only provides anext_pagecursor.Solution
Instead of relying on crates.io to provide the previous page link, docs.rs now tracks the page number itself:
page=Nto crates.io in search requests, enabling page-based pagination alongside seek paginationN-1next_pageresponse (unchanged behavior)Changes
crates/bin/docs_rs_web/src/handlers/releases.rs: Addedpage=1to initial search query params; inget_search_results, extract the page number from query params and computeprev_pagewhenpage > 1Testing
cargo check -p docs_rs_webpasses