Results Array Question

Hello -

I’m implementing pagination on a results page for a client and I would like the results cards to be numbered. I’ve added a div next to each results card that includes the index of each result which is great for the first 20 results on page 1. However, if i move to page 2, I do get the next 20 results but it looks like the array indexes still remain 1-20 instead of 21-30. I do want to keep the max of results displayed at 20 on any given page but I want to be able to get the accurate index number for each result. It doesn’t appear that I have access to the full results array in state which I have already explored. Can you help with a workaround?

If you’re keeping track of the page number, you could do ((page_number - 1) * results_per_page) + 1 to get your starting index for that page.

Or, you can also just using the search state to get the current offset and add one to that to get the starting index for the page.