Tuning the structure and properties of nitrogen-rich covalent organic frameworks by molecular design and solid state reactions