How to use a contextual filter value in a menu displayed on the same page
Something about the answer by @No Sssweat got me thinking, so I searched differently and discovered that arguments.field_topic_target_id contains the value from the contextual filter. So, the answer is to my question is to use:

/books-by-popularity/{{ arguments.field_topic_target_id }}


as the Popularity link in the menu. Credit to @No Sssweat for providing the spark!