@sentecacommerce-theme/lib 0.13.20 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/analytics/Releva/api/query/useRelevaQuery.js +1 -1
- package/dist/cjs/api/getSDKConfig.js +4 -4
- package/dist/cjs/api/notificationsApi/index.js +6 -2
- package/dist/cjs/hooks/useProduct/index.js +2 -2
- package/dist/cjs/hooks/useProduct/utils/index.js +1 -1
- package/dist/cjs/seo/api/ssr/fetchRedirectByFrom.js +2 -5
- package/dist/cjs/seo/components/ProductSEO/index.js +5 -5
- package/dist/esm/analytics/Releva/api/query/useRelevaQuery.js +1 -1
- package/dist/esm/api/getSDKConfig.js +5 -5
- package/dist/esm/api/notificationsApi/index.js +6 -2
- package/dist/esm/hooks/useProduct/index.js +2 -2
- package/dist/esm/hooks/useProduct/utils/index.js +1 -1
- package/dist/esm/seo/api/ssr/fetchRedirectByFrom.js +2 -5
- package/dist/esm/seo/components/ProductSEO/index.js +5 -5
- package/dist/types/hooks/useProduct/index.d.ts +2 -1
- package/dist/types/seo/components/ProductSEO/index.d.ts +2 -1
- package/package.json +4 -4
@@ -44,7 +44,7 @@ var useRelevaQuery = function(payload, isReady, token, interfaceKey) {
|
|
44
44
|
return _regeneratorRuntime.default.wrap(function _callee$(_ctx) {
|
45
45
|
while(1)switch(_ctx.prev = _ctx.next){
|
46
46
|
case 0:
|
47
|
-
url =
|
47
|
+
url = "".concat(process.env.NEXT_PUBLIC_PROXY_URL, "/hub/releva/collect");
|
48
48
|
return _ctx.abrupt("return", fetch(url, {
|
49
49
|
method: 'POST',
|
50
50
|
headers: {
|
@@ -53,18 +53,18 @@ var getSDKConfig = function() {
|
|
53
53
|
exports.getSDKConfig = getSDKConfig;
|
54
54
|
var getOptions = function() {
|
55
55
|
var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
56
|
+
var ref;
|
57
|
+
var basePath = process.env.NEXT_PUBLIC_PROXY_URL + ((ref = options === null || options === void 0 ? void 0 : options.basePath) !== null && ref !== void 0 ? ref : '/platform');
|
56
58
|
if (!(0, _utils).canUseDOM()) {
|
57
59
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
58
60
|
var nodeFetch = require('node-fetch');
|
59
|
-
var ref;
|
60
61
|
return _objectSpread({}, options, {
|
61
|
-
basePath:
|
62
|
+
basePath: basePath,
|
62
63
|
fetchApi: nodeFetch
|
63
64
|
}, process.env.sdkConfig || {});
|
64
65
|
} else {
|
65
|
-
var ref2;
|
66
66
|
return _objectSpread({}, options, {
|
67
|
-
basePath:
|
67
|
+
basePath: basePath,
|
68
68
|
token: _jsCookie.default.get(_utils.AUTH_TOKEN_KEY) || _jsCookie.default.get(_utils.ANONYMOUS_TOKEN_KEY) || process.env.API_KEY || process.env.apiKey,
|
69
69
|
fetchApi: window.fetch.bind(window)
|
70
70
|
}, process.env.sdkConfig || {});
|
@@ -33,7 +33,9 @@ var NotificationsApiFactory = function() {
|
|
33
33
|
queryCache.cancelQueries(cacheKeys.useGet);
|
34
34
|
var oldNotifications = queryCache.getQueryData(cacheKeys.useGet);
|
35
35
|
return function() {
|
36
|
-
return queryCache.setQueryData(cacheKeys.useGet,
|
36
|
+
return queryCache.setQueryData(cacheKeys.useGet, {
|
37
|
+
results: oldNotifications
|
38
|
+
});
|
37
39
|
};
|
38
40
|
},
|
39
41
|
onError: function(_, __, rollback) {
|
@@ -44,7 +46,9 @@ var NotificationsApiFactory = function() {
|
|
44
46
|
var optimisticNotifications = previousNotifications === null || previousNotifications === void 0 ? void 0 : previousNotifications.results.filter(function(n) {
|
45
47
|
return n._id !== params.id;
|
46
48
|
});
|
47
|
-
queryCache.setQueryData(cacheKeys.useGet,
|
49
|
+
queryCache.setQueryData(cacheKeys.useGet, {
|
50
|
+
results: optimisticNotifications
|
51
|
+
});
|
48
52
|
onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess();
|
49
53
|
}
|
50
54
|
});
|
@@ -19,7 +19,7 @@ function _interopRequireDefault(obj) {
|
|
19
19
|
var ProductStateContext = /*#__PURE__*/ _react.default.createContext(undefined);
|
20
20
|
var CountDispatchContext = /*#__PURE__*/ _react.default.createContext(undefined);
|
21
21
|
function ProductProvider(param) {
|
22
|
-
var product = param.product, children = param.children, defaultVariantId = param.defaultVariantId, _includeBrandInName = param.includeBrandInName, includeBrandInName = _includeBrandInName === void 0 ? false : _includeBrandInName;
|
22
|
+
var product = param.product, children = param.children, defaultVariantId = param.defaultVariantId, _includeBrandInName = param.includeBrandInName, includeBrandInName = _includeBrandInName === void 0 ? false : _includeBrandInName, _withShortTitle = param.withShortTitle, withShortTitle = _withShortTitle === void 0 ? false : _withShortTitle;
|
23
23
|
var ref38 = (0, _useProductVariants).useProductVariants({
|
24
24
|
product: product,
|
25
25
|
defaultVariantId: defaultVariantId
|
@@ -30,7 +30,7 @@ function ProductProvider(param) {
|
|
30
30
|
var rootCategoryId = rootCategory === null || rootCategory === void 0 ? void 0 : rootCategory.resourceId;
|
31
31
|
var metaObj = {
|
32
32
|
_id: product === null || product === void 0 ? void 0 : product._id,
|
33
|
-
name: includeBrandInName && (product === null || product === void 0 ? void 0 : (ref1 = product.brands) === null || ref1 === void 0 ? void 0 : (ref2 = ref1[0]) === null || ref2 === void 0 ? void 0 : (ref3 = ref2.resource) === null || ref3 === void 0 ? void 0 : ref3.name) ? "".concat((0, _).getTranslatableField(product === null || product === void 0 ? void 0 : (ref4 = product.brands) === null || ref4 === void 0 ? void 0 : (ref5 = ref4[0]) === null || ref5 === void 0 ? void 0 : (ref6 = ref5.resource) === null || ref6 === void 0 ? void 0 : ref6.name), " ").concat((0, _).getTranslatableField(selectedVariant === null || selectedVariant === void 0 ? void 0 : selectedVariant.name) || (0, _).getTranslatableField(product === null || product === void 0 ? void 0 : product.name)) : (0, _).getTranslatableField(selectedVariant === null || selectedVariant === void 0 ? void 0 : selectedVariant.name) || (0, _).getTranslatableField(product === null || product === void 0 ? void 0 : product.name),
|
33
|
+
name: includeBrandInName && !withShortTitle && (product === null || product === void 0 ? void 0 : (ref1 = product.brands) === null || ref1 === void 0 ? void 0 : (ref2 = ref1[0]) === null || ref2 === void 0 ? void 0 : (ref3 = ref2.resource) === null || ref3 === void 0 ? void 0 : ref3.name) ? "".concat((0, _).getTranslatableField(product === null || product === void 0 ? void 0 : (ref4 = product.brands) === null || ref4 === void 0 ? void 0 : (ref5 = ref4[0]) === null || ref5 === void 0 ? void 0 : (ref6 = ref5.resource) === null || ref6 === void 0 ? void 0 : ref6.name), " ").concat((0, _).getTranslatableField(selectedVariant === null || selectedVariant === void 0 ? void 0 : selectedVariant.name) || (0, _).getTranslatableField(product === null || product === void 0 ? void 0 : product.name)) : (0, _).getTranslatableField(selectedVariant === null || selectedVariant === void 0 ? void 0 : selectedVariant.name) || (0, _).getTranslatableField(product === null || product === void 0 ? void 0 : product.name),
|
34
34
|
slug: (0, _).getTranslatableField(product === null || product === void 0 ? void 0 : product.slug),
|
35
35
|
description: (0, _).getTranslatableField(selectedVariant === null || selectedVariant === void 0 ? void 0 : selectedVariant.description) || (0, _).getTranslatableField(product === null || product === void 0 ? void 0 : product.description),
|
36
36
|
shortDescription: (0, _).getTranslatableField(selectedVariant === null || selectedVariant === void 0 ? void 0 : selectedVariant.metaDescription) || (0, _).getTranslatableField(product === null || product === void 0 ? void 0 : product.metaDescription),
|
@@ -226,7 +226,7 @@ exports.createMappedAttributes = createMappedAttributes;
|
|
226
226
|
var processAvailabilityPerStore = function(availabilities) {
|
227
227
|
var ref;
|
228
228
|
return (ref = availabilities === null || availabilities === void 0 ? void 0 : availabilities.filter(function(x) {
|
229
|
-
return
|
229
|
+
return x.availableQuantity > 0;
|
230
230
|
})) === null || ref === void 0 ? void 0 : ref.map(function(param) {
|
231
231
|
var acceptsBackorders = param.acceptsBackorders, stockLocationName = param.stockLocationName, restockableInDays = param.restockableInDays, availableQuantity = param.availableQuantity;
|
232
232
|
return {
|
@@ -40,17 +40,14 @@ function _interopRequireDefault(obj) {
|
|
40
40
|
}
|
41
41
|
var fetchRedirectByFrom = function() {
|
42
42
|
var _ref = _asyncToGenerator(_regeneratorRuntime.default.mark(function _callee(from) {
|
43
|
-
var redirectUrl;
|
44
43
|
return _regeneratorRuntime.default.wrap(function _callee$(_ctx) {
|
45
44
|
while(1)switch(_ctx.prev = _ctx.next){
|
46
45
|
case 0:
|
47
46
|
_ctx.next = 2;
|
48
47
|
return (0, _sdk).RedirectsGetByFrom(from);
|
49
48
|
case 2:
|
50
|
-
|
51
|
-
|
52
|
-
return _ctx.abrupt("return", redirectUrl);
|
53
|
-
case 5:
|
49
|
+
return _ctx.abrupt("return", _ctx.sent);
|
50
|
+
case 3:
|
54
51
|
case "end":
|
55
52
|
return _ctx.stop();
|
56
53
|
}
|
@@ -28,17 +28,17 @@ function _interopRequireDefault(obj) {
|
|
28
28
|
*
|
29
29
|
*/ var truncateToCharLength = function(text, maxLenChars) {
|
30
30
|
var separator = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : ' ';
|
31
|
-
var cut = text.indexOf(separator, maxLenChars);
|
31
|
+
var cut = text === null || text === void 0 ? void 0 : text.indexOf(separator, maxLenChars);
|
32
32
|
if (cut === -1) return text;
|
33
|
-
return text.substring(0, cut);
|
33
|
+
return text === null || text === void 0 ? void 0 : text.substring(0, cut);
|
34
34
|
};
|
35
35
|
function ProductSEO() {
|
36
|
-
var ref16 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, _favorTitleTemplateOverMeta = ref16.favorTitleTemplateOverMeta, favorTitleTemplateOverMeta = _favorTitleTemplateOverMeta === void 0 ? false : _favorTitleTemplateOverMeta, _favorDescriptionTemplateOverMeta = ref16.favorDescriptionTemplateOverMeta, favorDescriptionTemplateOverMeta = _favorDescriptionTemplateOverMeta === void 0 ? false : _favorDescriptionTemplateOverMeta, _titleTemplate = ref16.titleTemplate, titleTemplate = _titleTemplate === void 0 ? ':title:' : _titleTemplate, _descriptionTemplate = ref16.descriptionTemplate, descriptionTemplate = _descriptionTemplate === void 0 ? ':description:' : _descriptionTemplate;
|
36
|
+
var ref16 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, _favorTitleTemplateOverMeta = ref16.favorTitleTemplateOverMeta, favorTitleTemplateOverMeta = _favorTitleTemplateOverMeta === void 0 ? false : _favorTitleTemplateOverMeta, _favorDescriptionTemplateOverMeta = ref16.favorDescriptionTemplateOverMeta, favorDescriptionTemplateOverMeta = _favorDescriptionTemplateOverMeta === void 0 ? false : _favorDescriptionTemplateOverMeta, _titleTemplate = ref16.titleTemplate, titleTemplate = _titleTemplate === void 0 ? ':title:' : _titleTemplate, _descriptionTemplate = ref16.descriptionTemplate, descriptionTemplate = _descriptionTemplate === void 0 ? ':description:' : _descriptionTemplate, _withShortTitle = ref16.withShortTitle, withShortTitle = _withShortTitle === void 0 ? false : _withShortTitle;
|
37
37
|
var ref1, ref2, ref3, ref4, ref5, ref6, ref7, ref8, ref9, ref10, ref11, ref12, ref13, ref14;
|
38
38
|
var ref15 = (0, _useProduct).useProductState(), selectedVariant = ref15.selectedVariant, metaData = ref15.metaData, seoData = ref15.seoData;
|
39
39
|
var domain = (0, _useConfig).useConfigState().domain;
|
40
40
|
var description = (0, _utils).escape(seoData.description || metaData.shortDescription || truncateToCharLength(metaData === null || metaData === void 0 ? void 0 : metaData.description, 200) || '');
|
41
|
-
var title = seoData.title || metaData.name || '';
|
41
|
+
var title = withShortTitle ? metaData.name || '' : seoData.title || metaData.name || '';
|
42
42
|
var price = (0, _usePrice).usePrice({
|
43
43
|
price: selectedVariant === null || selectedVariant === void 0 ? void 0 : (ref1 = selectedVariant.offer) === null || ref1 === void 0 ? void 0 : ref1.originalPrice
|
44
44
|
}).price;
|
@@ -63,7 +63,7 @@ function ProductSEO() {
|
|
63
63
|
type: "application/ld+json",
|
64
64
|
dangerouslySetInnerHTML: (0, _utils).createDangerousMarkup(productJSONLd)
|
65
65
|
})), /*#__PURE__*/ _react.default.createElement(_basicSEO.BasicSEO, {
|
66
|
-
title: formattedTitle,
|
66
|
+
title: withShortTitle ? title : formattedTitle,
|
67
67
|
description: formattedDescription,
|
68
68
|
keywords: seoData.keywords
|
69
69
|
}), /*#__PURE__*/ _react.default.createElement(_openGraph.OpenGraph, {
|
@@ -35,7 +35,7 @@ export var useRelevaQuery = function(payload, isReady, token, interfaceKey) {
|
|
35
35
|
return regeneratorRuntime.wrap(function _callee$(_ctx) {
|
36
36
|
while(1)switch(_ctx.prev = _ctx.next){
|
37
37
|
case 0:
|
38
|
-
url =
|
38
|
+
url = "".concat(process.env.NEXT_PUBLIC_PROXY_URL, "/hub/releva/collect");
|
39
39
|
return _ctx.abrupt("return", fetch(url, {
|
40
40
|
method: 'POST',
|
41
41
|
headers: {
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { Configuration, HttpClient } from '@sentecacommerce/sdk';
|
2
2
|
import Cookies from 'js-cookie';
|
3
|
-
import { ANONYMOUS_TOKEN_KEY, AUTH_TOKEN_KEY,
|
3
|
+
import { ANONYMOUS_TOKEN_KEY, AUTH_TOKEN_KEY, canUseDOM, getLocaleFromPath } from '../utils';
|
4
4
|
function _defineProperty(obj, key, value) {
|
5
5
|
if (key in obj) {
|
6
6
|
Object.defineProperty(obj, key, {
|
@@ -43,18 +43,18 @@ export var getSDKConfig = function() {
|
|
43
43
|
};
|
44
44
|
export var getOptions = function() {
|
45
45
|
var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
46
|
+
var ref;
|
47
|
+
var basePath = process.env.NEXT_PUBLIC_PROXY_URL + ((ref = options === null || options === void 0 ? void 0 : options.basePath) !== null && ref !== void 0 ? ref : '/platform');
|
46
48
|
if (!canUseDOM()) {
|
47
49
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
48
50
|
var nodeFetch = require('node-fetch');
|
49
|
-
var ref;
|
50
51
|
return _objectSpread({}, options, {
|
51
|
-
basePath:
|
52
|
+
basePath: basePath,
|
52
53
|
fetchApi: nodeFetch
|
53
54
|
}, process.env.sdkConfig || {});
|
54
55
|
} else {
|
55
|
-
var ref2;
|
56
56
|
return _objectSpread({}, options, {
|
57
|
-
basePath:
|
57
|
+
basePath: basePath,
|
58
58
|
token: Cookies.get(AUTH_TOKEN_KEY) || Cookies.get(ANONYMOUS_TOKEN_KEY) || process.env.API_KEY || process.env.apiKey,
|
59
59
|
fetchApi: window.fetch.bind(window)
|
60
60
|
}, process.env.sdkConfig || {});
|
@@ -27,7 +27,9 @@ export var NotificationsApiFactory = function() {
|
|
27
27
|
queryCache.cancelQueries(cacheKeys.useGet);
|
28
28
|
var oldNotifications = queryCache.getQueryData(cacheKeys.useGet);
|
29
29
|
return function() {
|
30
|
-
return queryCache.setQueryData(cacheKeys.useGet,
|
30
|
+
return queryCache.setQueryData(cacheKeys.useGet, {
|
31
|
+
results: oldNotifications
|
32
|
+
});
|
31
33
|
};
|
32
34
|
},
|
33
35
|
onError: function(_, __, rollback) {
|
@@ -38,7 +40,9 @@ export var NotificationsApiFactory = function() {
|
|
38
40
|
var optimisticNotifications = previousNotifications === null || previousNotifications === void 0 ? void 0 : previousNotifications.results.filter(function(n) {
|
39
41
|
return n._id !== params.id;
|
40
42
|
});
|
41
|
-
queryCache.setQueryData(cacheKeys.useGet,
|
43
|
+
queryCache.setQueryData(cacheKeys.useGet, {
|
44
|
+
results: optimisticNotifications
|
45
|
+
});
|
42
46
|
onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess();
|
43
47
|
}
|
44
48
|
});
|
@@ -7,7 +7,7 @@ import { useProductVariants } from '../useProductVariants';
|
|
7
7
|
var ProductStateContext = /*#__PURE__*/ React.createContext(undefined);
|
8
8
|
var CountDispatchContext = /*#__PURE__*/ React.createContext(undefined);
|
9
9
|
export function ProductProvider(param) {
|
10
|
-
var product = param.product, children = param.children, defaultVariantId = param.defaultVariantId, _includeBrandInName = param.includeBrandInName, includeBrandInName = _includeBrandInName === void 0 ? false : _includeBrandInName;
|
10
|
+
var product = param.product, children = param.children, defaultVariantId = param.defaultVariantId, _includeBrandInName = param.includeBrandInName, includeBrandInName = _includeBrandInName === void 0 ? false : _includeBrandInName, _withShortTitle = param.withShortTitle, withShortTitle = _withShortTitle === void 0 ? false : _withShortTitle;
|
11
11
|
var ref38 = useProductVariants({
|
12
12
|
product: product,
|
13
13
|
defaultVariantId: defaultVariantId
|
@@ -18,7 +18,7 @@ export function ProductProvider(param) {
|
|
18
18
|
var rootCategoryId = rootCategory === null || rootCategory === void 0 ? void 0 : rootCategory.resourceId;
|
19
19
|
var metaObj = {
|
20
20
|
_id: product === null || product === void 0 ? void 0 : product._id,
|
21
|
-
name: includeBrandInName && (product === null || product === void 0 ? void 0 : (ref1 = product.brands) === null || ref1 === void 0 ? void 0 : (ref2 = ref1[0]) === null || ref2 === void 0 ? void 0 : (ref3 = ref2.resource) === null || ref3 === void 0 ? void 0 : ref3.name) ? "".concat(getTranslatableField(product === null || product === void 0 ? void 0 : (ref4 = product.brands) === null || ref4 === void 0 ? void 0 : (ref5 = ref4[0]) === null || ref5 === void 0 ? void 0 : (ref6 = ref5.resource) === null || ref6 === void 0 ? void 0 : ref6.name), " ").concat(getTranslatableField(selectedVariant === null || selectedVariant === void 0 ? void 0 : selectedVariant.name) || getTranslatableField(product === null || product === void 0 ? void 0 : product.name)) : getTranslatableField(selectedVariant === null || selectedVariant === void 0 ? void 0 : selectedVariant.name) || getTranslatableField(product === null || product === void 0 ? void 0 : product.name),
|
21
|
+
name: includeBrandInName && !withShortTitle && (product === null || product === void 0 ? void 0 : (ref1 = product.brands) === null || ref1 === void 0 ? void 0 : (ref2 = ref1[0]) === null || ref2 === void 0 ? void 0 : (ref3 = ref2.resource) === null || ref3 === void 0 ? void 0 : ref3.name) ? "".concat(getTranslatableField(product === null || product === void 0 ? void 0 : (ref4 = product.brands) === null || ref4 === void 0 ? void 0 : (ref5 = ref4[0]) === null || ref5 === void 0 ? void 0 : (ref6 = ref5.resource) === null || ref6 === void 0 ? void 0 : ref6.name), " ").concat(getTranslatableField(selectedVariant === null || selectedVariant === void 0 ? void 0 : selectedVariant.name) || getTranslatableField(product === null || product === void 0 ? void 0 : product.name)) : getTranslatableField(selectedVariant === null || selectedVariant === void 0 ? void 0 : selectedVariant.name) || getTranslatableField(product === null || product === void 0 ? void 0 : product.name),
|
22
22
|
slug: getTranslatableField(product === null || product === void 0 ? void 0 : product.slug),
|
23
23
|
description: getTranslatableField(selectedVariant === null || selectedVariant === void 0 ? void 0 : selectedVariant.description) || getTranslatableField(product === null || product === void 0 ? void 0 : product.description),
|
24
24
|
shortDescription: getTranslatableField(selectedVariant === null || selectedVariant === void 0 ? void 0 : selectedVariant.metaDescription) || getTranslatableField(product === null || product === void 0 ? void 0 : product.metaDescription),
|
@@ -230,7 +230,7 @@ export var createMappedAttributes = function(currentVariant) {
|
|
230
230
|
export var processAvailabilityPerStore = function(availabilities) {
|
231
231
|
var ref;
|
232
232
|
return (ref = availabilities === null || availabilities === void 0 ? void 0 : availabilities.filter(function(x) {
|
233
|
-
return
|
233
|
+
return x.availableQuantity > 0;
|
234
234
|
})) === null || ref === void 0 ? void 0 : ref.map(function(param) {
|
235
235
|
var acceptsBackorders = param.acceptsBackorders, stockLocationName = param.stockLocationName, restockableInDays = param.restockableInDays, availableQuantity = param.availableQuantity;
|
236
236
|
return {
|
@@ -31,17 +31,14 @@ function _asyncToGenerator(fn) {
|
|
31
31
|
}
|
32
32
|
export var fetchRedirectByFrom = function() {
|
33
33
|
var _ref = _asyncToGenerator(regeneratorRuntime.mark(function _callee(from) {
|
34
|
-
var redirectUrl;
|
35
34
|
return regeneratorRuntime.wrap(function _callee$(_ctx) {
|
36
35
|
while(1)switch(_ctx.prev = _ctx.next){
|
37
36
|
case 0:
|
38
37
|
_ctx.next = 2;
|
39
38
|
return RedirectsGetByFrom(from);
|
40
39
|
case 2:
|
41
|
-
|
42
|
-
|
43
|
-
return _ctx.abrupt("return", redirectUrl);
|
44
|
-
case 5:
|
40
|
+
return _ctx.abrupt("return", _ctx.sent);
|
41
|
+
case 3:
|
45
42
|
case "end":
|
46
43
|
return _ctx.stop();
|
47
44
|
}
|
@@ -18,17 +18,17 @@ import { useConfigState } from '../../../hooks/useConfig';
|
|
18
18
|
*
|
19
19
|
*/ var truncateToCharLength = function(text, maxLenChars) {
|
20
20
|
var separator = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : ' ';
|
21
|
-
var cut = text.indexOf(separator, maxLenChars);
|
21
|
+
var cut = text === null || text === void 0 ? void 0 : text.indexOf(separator, maxLenChars);
|
22
22
|
if (cut === -1) return text;
|
23
|
-
return text.substring(0, cut);
|
23
|
+
return text === null || text === void 0 ? void 0 : text.substring(0, cut);
|
24
24
|
};
|
25
25
|
export function ProductSEO() {
|
26
|
-
var ref16 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, _favorTitleTemplateOverMeta = ref16.favorTitleTemplateOverMeta, favorTitleTemplateOverMeta = _favorTitleTemplateOverMeta === void 0 ? false : _favorTitleTemplateOverMeta, _favorDescriptionTemplateOverMeta = ref16.favorDescriptionTemplateOverMeta, favorDescriptionTemplateOverMeta = _favorDescriptionTemplateOverMeta === void 0 ? false : _favorDescriptionTemplateOverMeta, _titleTemplate = ref16.titleTemplate, titleTemplate = _titleTemplate === void 0 ? ':title:' : _titleTemplate, _descriptionTemplate = ref16.descriptionTemplate, descriptionTemplate = _descriptionTemplate === void 0 ? ':description:' : _descriptionTemplate;
|
26
|
+
var ref16 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, _favorTitleTemplateOverMeta = ref16.favorTitleTemplateOverMeta, favorTitleTemplateOverMeta = _favorTitleTemplateOverMeta === void 0 ? false : _favorTitleTemplateOverMeta, _favorDescriptionTemplateOverMeta = ref16.favorDescriptionTemplateOverMeta, favorDescriptionTemplateOverMeta = _favorDescriptionTemplateOverMeta === void 0 ? false : _favorDescriptionTemplateOverMeta, _titleTemplate = ref16.titleTemplate, titleTemplate = _titleTemplate === void 0 ? ':title:' : _titleTemplate, _descriptionTemplate = ref16.descriptionTemplate, descriptionTemplate = _descriptionTemplate === void 0 ? ':description:' : _descriptionTemplate, _withShortTitle = ref16.withShortTitle, withShortTitle = _withShortTitle === void 0 ? false : _withShortTitle;
|
27
27
|
var ref1, ref2, ref3, ref4, ref5, ref6, ref7, ref8, ref9, ref10, ref11, ref12, ref13, ref14;
|
28
28
|
var ref15 = useProductState(), selectedVariant = ref15.selectedVariant, metaData = ref15.metaData, seoData = ref15.seoData;
|
29
29
|
var domain = useConfigState().domain;
|
30
30
|
var description = escape(seoData.description || metaData.shortDescription || truncateToCharLength(metaData === null || metaData === void 0 ? void 0 : metaData.description, 200) || '');
|
31
|
-
var title = seoData.title || metaData.name || '';
|
31
|
+
var title = withShortTitle ? metaData.name || '' : seoData.title || metaData.name || '';
|
32
32
|
var price = usePrice({
|
33
33
|
price: selectedVariant === null || selectedVariant === void 0 ? void 0 : (ref1 = selectedVariant.offer) === null || ref1 === void 0 ? void 0 : ref1.originalPrice
|
34
34
|
}).price;
|
@@ -53,7 +53,7 @@ export function ProductSEO() {
|
|
53
53
|
type: "application/ld+json",
|
54
54
|
dangerouslySetInnerHTML: createDangerousMarkup(productJSONLd)
|
55
55
|
})), /*#__PURE__*/ React.createElement(BasicSEO, {
|
56
|
-
title: formattedTitle,
|
56
|
+
title: withShortTitle ? title : formattedTitle,
|
57
57
|
description: formattedDescription,
|
58
58
|
keywords: seoData.keywords
|
59
59
|
}), /*#__PURE__*/ React.createElement(OpenGraph, {
|
@@ -55,6 +55,7 @@ declare type ProductProviderProps = {
|
|
55
55
|
project?: string;
|
56
56
|
};
|
57
57
|
includeBrandInName?: boolean;
|
58
|
+
withShortTitle?: boolean;
|
58
59
|
};
|
59
60
|
declare type ProductStateContextType = {
|
60
61
|
attributeRules: AttributeRulesMap;
|
@@ -91,7 +92,7 @@ declare type CountFunctionsContextType = {
|
|
91
92
|
};
|
92
93
|
getProductVideos: () => VideoType[];
|
93
94
|
};
|
94
|
-
export declare function ProductProvider({ product, children, defaultVariantId, includeBrandInName, }: ProductProviderProps): JSX.Element;
|
95
|
+
export declare function ProductProvider({ product, children, defaultVariantId, includeBrandInName, withShortTitle, }: ProductProviderProps): JSX.Element;
|
95
96
|
export declare function useProductState(): ProductStateContextType;
|
96
97
|
export declare function useProductFunctions(): CountFunctionsContextType;
|
97
98
|
export declare function useProduct(slug: string, config?: getProductBySlugConfig): import("react-query").QueryResult<ProductDTO, unknown>;
|
@@ -1,6 +1,7 @@
|
|
1
|
-
export declare function ProductSEO({ favorTitleTemplateOverMeta, favorDescriptionTemplateOverMeta, titleTemplate, descriptionTemplate, }?: {
|
1
|
+
export declare function ProductSEO({ favorTitleTemplateOverMeta, favorDescriptionTemplateOverMeta, titleTemplate, descriptionTemplate, withShortTitle, }?: {
|
2
2
|
favorTitleTemplateOverMeta?: boolean;
|
3
3
|
favorDescriptionTemplateOverMeta?: boolean;
|
4
4
|
titleTemplate?: string;
|
5
5
|
descriptionTemplate?: string;
|
6
|
+
withShortTitle?: boolean;
|
6
7
|
}): JSX.Element;
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@sentecacommerce-theme/lib",
|
3
3
|
"sideEffects": false,
|
4
|
-
"version": "0.
|
4
|
+
"version": "0.14.0",
|
5
5
|
"main": "dist/cjs/index.js",
|
6
6
|
"module": "dist/esm/index.js",
|
7
7
|
"types": "dist/types/index.d.ts",
|
@@ -31,13 +31,13 @@
|
|
31
31
|
"watch:cjs": "swc src --out-dir dist/cjs -w",
|
32
32
|
"watch:esm": "swc src --out-dir dist/esm --no-swcrc -w"
|
33
33
|
},
|
34
|
-
"gitHead": "
|
34
|
+
"gitHead": "0a0899c89fc51a7baa0c955c62aadee8e4bd3544",
|
35
35
|
"peerDependencies": {
|
36
36
|
"react-query": "^2.26.2"
|
37
37
|
},
|
38
38
|
"dependencies": {
|
39
|
-
"@sentecacommerce-theme/base": "^0.
|
40
|
-
"@sentecacommerce-theme/cms": "^0.
|
39
|
+
"@sentecacommerce-theme/base": "^0.14.0",
|
40
|
+
"@sentecacommerce-theme/cms": "^0.14.0",
|
41
41
|
"@sentecacommerce/sdk": "2.0.175",
|
42
42
|
"body-scroll-lock": "^3.1.5",
|
43
43
|
"copy-to-clipboard": "^3.3.1",
|