diff --git a/components/Snipcart.js b/components/Snipcart.js index cb1c876..951183b 100644 --- a/components/Snipcart.js +++ b/components/Snipcart.js @@ -7,7 +7,8 @@ var Snipcart = function Snipcart(_ref) { currency = _ref.currency, innerHTML = _ref.innerHTML, openCartOnAdd = _ref.openCartOnAdd, - useSideCart = _ref.useSideCart; + useSideCart = _ref.useSideCart, + templatesUrl = _ref.templatesUrl; return /*#__PURE__*/React.createElement("div", { hidden: true, id: "snipcart", @@ -15,6 +16,7 @@ var Snipcart = function Snipcart(_ref) { "data-currency": currency, "data-config-add-product-behavior": openCartOnAdd === false ? "none" : null, "data-config-modal-style": useSideCart === true ? "side" : null, + "data-templates-url": {}, dangerouslySetInnerHTML: { __html: "\n " + innerHTML + "\n " } @@ -25,6 +27,7 @@ Snipcart.defaultProps = { currency: "usd", innerHTML: "", openCartOnAdd: true, - useSideCart: false + useSideCart: false, + templatesUrl: null }; module.exports = Snipcart; \ No newline at end of file diff --git a/gatsby-ssr.js b/gatsby-ssr.js index 248cead..b8c8213 100644 --- a/gatsby-ssr.js +++ b/gatsby-ssr.js @@ -29,7 +29,8 @@ exports.onRenderBody = function (_ref, pluginOptions) { version: "3.0.19", innerHTML: "", openCartOnAdd: true, - useSideCart: false + useSideCart: false, + templatesUrl: null }, pluginOptions); // find public api key in options plugin or environment variable @@ -50,7 +51,8 @@ exports.onRenderBody = function (_ref, pluginOptions) { , currency: provideDefaultCurrency ? _options.currency : null, openCartOnAdd: _options.openCartOnAdd, - useSideCart: _options.useSideCart + useSideCart: _options.useSideCart, + templatesUrl: _options.templatesUrl }), /*#__PURE__*/ // insert style diff --git a/package.json b/package.json index 0554420..7bc85f0 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "gatsby-plugin-snipcart-advanced", "main": "gatsby-ssr.js", - "version": "1.0.2-beta", + "version": "1.0.4-beta", "description": "Gatsby JS Plugin for Snipcart V3", "keywords": [ "gatsby", diff --git a/readme.md b/readme.md index c2b17ba..0511a7b 100644 --- a/readme.md +++ b/readme.md @@ -47,7 +47,7 @@ module.exports = { }, }, templatesUrl: - "path on your template file. Set file in the static folder", + "path on your template file. Set file in the static folder, ex: '/snipcart/index.html'", // not work on dev. Gatsby not serve html file in dev https://github.com/gatsbyjs/gatsby/issues/13072 innerHTML: ` diff --git a/src/components/Snipcart.jsx b/src/components/Snipcart.jsx index 0cad1f4..38c7836 100644 --- a/src/components/Snipcart.jsx +++ b/src/components/Snipcart.jsx @@ -15,7 +15,7 @@ const Snipcart = ({ data-currency={currency} data-config-add-product-behavior={openCartOnAdd === false ? "none" : null} data-config-modal-style={useSideCart === true ? "side" : null} - data-templates-url={{}} + data-templates-url={templatesUrl} dangerouslySetInnerHTML={{ __html: ` ${innerHTML}