diff --git a/lib/generators/shopify_app/home_controller/templates/index.html.erb b/lib/generators/shopify_app/home_controller/templates/index.html.erb index 87ba2085a..752f63cee 100644 --- a/lib/generators/shopify_app/home_controller/templates/index.html.erb +++ b/lib/generators/shopify_app/home_controller/templates/index.html.erb @@ -7,48 +7,52 @@ rel="stylesheet" href="https://unpkg.com/@shopify/polaris@4.25.0/styles.min.css" /> -<% if embedded_app? %> -<% end %> + if (products === undefined || products.length == 0) { + document.getElementById("products").innerHTML = "
No products to display."; + } else { + var list = ""; + products.forEach((product) => { + var link = `` + list += "
  • " + link + product.title + "
  • "; + }); + document.getElementById("products").innerHTML = ""; + } + }); + }(); + }; + + <% if ShopifyApp.use_importmap? %> + import "lib/shopify_app" + displayProducts(); + <% else %> + document.addEventListener("DOMContentLoaded", displayProducts); + <% end %> + + <% end %> +

    Products

    <% if embedded_app? %>

    Loading...
    <% else %>