Infinite pagination with page numbers

I’m trying to enhance my infinitely paginated search results with page numbers that appear every 10 results (see for an example). Using Blaze, I’m having a hard time doing this “correctly.” I’ve managed to implement a mostly working solution but it’s not tolerant of result resorting. Here’s my jQuery based solution:

Template.documentsTable.rendered = (->
    page = (Session.get('limit') / 10) - 1;
    @$('#documents-table--table tbody tr:last')

What’s a better way to correctly inject a view after N results and remove it when a re-sort occurs?