Managing light in optoelectronic devices with resonant optical nanostructures