A Riemann–Hilbert method to algebro-geometric solutions of the Korteweg–de Vries equation