It's not consistent with the 1st Amendment — the 1st constrains Congress from enacting certain classes of law. This is not any of those prohibitions, but it is prohibited by the 13th.
The Court ruling applies the 1st Amendment to a California anti-discrimination law that has the effect of forcing a baker to engage in speech they do not want to. There is a long history of applying constitutional provisions to state laws which violate them.
So, in fact the ruling fits in the very category you identified. Here is the opinion