From 49f0ab18646773cbe3c5629b046765ae8200317f Mon Sep 17 00:00:00 2001 From: Leonardo Matos Date: Fri, 3 Apr 2020 04:27:04 -0300 Subject: [PATCH] chore(ejs): minor style fixes and update sections [skip ci] --- .../pages/@/sections/collection-shelf.ejs | 49 +++++++++---------- .../pages/@/sections/custom-content.ejs | 3 ++ .../template/pages/@/sections/custom-html.ejs | 9 ++++ .../template/pages/@/sections/inc/banner.ejs | 15 ++++++ .../pages/@/sections/inc/md-content.ejs | 4 +- .../@/sections/inc/products-carousel.ejs | 13 ++++- .../pages/@/sections/search-engine.ejs | 4 +- 7 files changed, 63 insertions(+), 34 deletions(-) create mode 100644 @ecomplus/storefront-template/template/pages/@/sections/custom-content.ejs create mode 100644 @ecomplus/storefront-template/template/pages/@/sections/custom-html.ejs diff --git a/@ecomplus/storefront-template/template/pages/@/sections/collection-shelf.ejs b/@ecomplus/storefront-template/template/pages/@/sections/collection-shelf.ejs index fe5a3c5ac..acd43a6aa 100644 --- a/@ecomplus/storefront-template/template/pages/@/sections/collection-shelf.ejs +++ b/@ecomplus/storefront-template/template/pages/@/sections/collection-shelf.ejs @@ -1,29 +1,24 @@ -
- <% - if (opt.collection_id) { - const res = await _.ecomClient.store({ - url: `/collections/${opt.collection_id}.json` - }) - const collection = res.data - let items = [] - if (Array.isArray(collection.products) && collection.products.length) { - const search = new _.EcomSearch() - await search.setProductIds(collection.products).fetch() - items = search.getItems() - } - const { title, link } = opt - - %> - <%- await include('/@/sections/inc/products-carousel', { - _, opt: { items, collection, title, link } - }) %> - <% - } else { - %> - <%- await include('/@/sections/inc/products-carousel', { - _, opt: { items: _.items } - }) %> - <% +<% +const { title, link, shuffle } = opt +let items, collection +if (opt.collection_id) { + const res = await _.ecomClient.store({ + url: `/collections/${opt.collection_id}.json` + }) + collection = res.data + items = [] + if (Array.isArray(collection.products) && collection.products.length) { + const search = new _.EcomSearch() + await search.setProductIds(collection.products).fetch() + items = search.getItems() } - %> +} else { + items = _.items +} +%> + +
+ <%- await include('/@/sections/inc/products-carousel', { + _, opt: { items, collection, title, link, shuffle } + }) %>
diff --git a/@ecomplus/storefront-template/template/pages/@/sections/custom-content.ejs b/@ecomplus/storefront-template/template/pages/@/sections/custom-content.ejs new file mode 100644 index 000000000..38c91d510 --- /dev/null +++ b/@ecomplus/storefront-template/template/pages/@/sections/custom-content.ejs @@ -0,0 +1,3 @@ +
+ <%- await include('/@/sections/inc/md-content') %> +
diff --git a/@ecomplus/storefront-template/template/pages/@/sections/custom-html.ejs b/@ecomplus/storefront-template/template/pages/@/sections/custom-html.ejs new file mode 100644 index 000000000..1a1c78315 --- /dev/null +++ b/@ecomplus/storefront-template/template/pages/@/sections/custom-html.ejs @@ -0,0 +1,9 @@ +<% if (typeof opt.html === 'string') { %> +
+
+
+ <%- opt.html %> +
+
+
+<% } %> diff --git a/@ecomplus/storefront-template/template/pages/@/sections/inc/banner.ejs b/@ecomplus/storefront-template/template/pages/@/sections/inc/banner.ejs index e62f046dc..247adbb70 100644 --- a/@ecomplus/storefront-template/template/pages/@/sections/inc/banner.ejs +++ b/@ecomplus/storefront-template/template/pages/@/sections/inc/banner.ejs @@ -1,7 +1,22 @@ +<% +let dimensions +if (opt.img.startsWith('/')) { + try { + dimensions = _.imageSize(`template/public${opt.img}`) + } catch (e) { + dimensions = null + } +} +%> +