need help making new anvil recipes

so im making a combat overhaul datapack and one of the main features is to be able to put a rune (custom craftable item) on your weapon. each weapon can have one rune. the rune can be connected to the weapon in an anvil. when you apply the rune to the weapon, it keeps all its previous data and gets a new custom_data component with the rune's name inside it. how can i do that?
Continue to help post