Engineering the excitonic and photonic properties of atomically thin semiconductors