The period–luminosity relation of red supergiants with Gaia DR2