Embedding heteroatoms into the main backbones of polymeric materials has become an efficient tool for tailoring their structures and improving their properties. However, owing to comparatively harsh heteroatom-doping conditions, this has rarely been explored in covalent organic frameworks (COFs). Herein, upon aldol condensation of a trimethyl-substituted pyrylium salt with a tritopic aromatic aldehyde, a two-dimensional oxonium-embedded COF with vinylene linkages was achieved, which was further converted to a neutral pyridine-cored COF by in situ replacement of oxonium ions with nitrogen atoms under ammonia treatment. The two heteroatom-embedded COFs are conceptually isoelectronic with each other, featuring similar geometric structures but different electronic structures, rendering them capable of catalyzing the visible-light-promoted multi-component synthesis of tri-substituted pyridine derivatives with good recyclability.