How can I make my popup modal dynamic on a product page?

Hey there,

I have a not so efficient setup that I think can be optimised and would like some help.

My requirements are that I have multiple elements on a product page that need their own separate popups. I have a page setup for each of these popup content and am using the following in the product-template to call the modal from the theme.liquid

Snippet from the Product-template:

 {% include 'icon-afterpay' %}

Code from the theme:


  	
 	
X

  	{{ pages.afterpay.content }}

The problem is that I dont know how to make this dynamic, as what I have done is copy and paste the above with different data-popup-modal:

Any help would be much appreciated. Also not looking for an app to help with this.

Thanks