Move `navbar_menu` block into the common layout and improve it.

It now looks for the longest API path match on active tab selection.