@sentecacommerce-theme/lib 0.13.12 → 0.13.13

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.
@@ -16,12 +16,28 @@ function _interopRequireDefault(obj) {
16
16
  default: obj
17
17
  };
18
18
  }
19
+ /**
20
+ * Template Options:
21
+ * :title: -> is going to be replace with the title
22
+ * :name: -> is going to be replace with the name
23
+ * :description: -> is going to be replace with the description
24
+ * :category: -> is going to be replace with the category
25
+ * :price: -> is going to be replace with the price
26
+ * :quantity: -> is going to be replace with the quantity
27
+ * :brand: -> is going to be replace with the brand
28
+ *
29
+ */ var truncateToCharLength = function(text, maxLenChars) {
30
+ var separator = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : ' ';
31
+ var cut = text.indexOf(separator, maxLenChars);
32
+ if (cut === -1) return text;
33
+ return text.substring(0, cut);
34
+ };
19
35
  function ProductSEO() {
20
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;
21
37
  var ref1, ref2, ref3, ref4, ref5, ref6, ref7, ref8, ref9, ref10, ref11, ref12, ref13, ref14;
22
38
  var ref15 = (0, _useProduct).useProductState(), selectedVariant = ref15.selectedVariant, metaData = ref15.metaData, seoData = ref15.seoData;
23
39
  var domain = (0, _useConfig).useConfigState().domain;
24
- var description = (0, _utils).escape(seoData.description || metaData.shortDescription || metaData.description || '');
40
+ var description = (0, _utils).escape(seoData.description || metaData.shortDescription || truncateToCharLength(metaData === null || metaData === void 0 ? void 0 : metaData.description, 200) || '');
25
41
  var title = seoData.title || metaData.name || '';
26
42
  var price = (0, _usePrice).usePrice({
27
43
  price: selectedVariant === null || selectedVariant === void 0 ? void 0 : (ref1 = selectedVariant.offer) === null || ref1 === void 0 ? void 0 : ref1.originalPrice
@@ -16,12 +16,18 @@ import { useConfigState } from '../../../hooks/useConfig';
16
16
  * :quantity: -> is going to be replace with the quantity
17
17
  * :brand: -> is going to be replace with the brand
18
18
  *
19
- */ export function ProductSEO() {
19
+ */ var truncateToCharLength = function(text, maxLenChars) {
20
+ var separator = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : ' ';
21
+ var cut = text.indexOf(separator, maxLenChars);
22
+ if (cut === -1) return text;
23
+ return text.substring(0, cut);
24
+ };
25
+ export function ProductSEO() {
20
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;
21
27
  var ref1, ref2, ref3, ref4, ref5, ref6, ref7, ref8, ref9, ref10, ref11, ref12, ref13, ref14;
22
28
  var ref15 = useProductState(), selectedVariant = ref15.selectedVariant, metaData = ref15.metaData, seoData = ref15.seoData;
23
29
  var domain = useConfigState().domain;
24
- var description = escape(seoData.description || metaData.shortDescription || metaData.description || '');
30
+ var description = escape(seoData.description || metaData.shortDescription || truncateToCharLength(metaData === null || metaData === void 0 ? void 0 : metaData.description, 200) || '');
25
31
  var title = seoData.title || metaData.name || '';
26
32
  var price = usePrice({
27
33
  price: selectedVariant === null || selectedVariant === void 0 ? void 0 : (ref1 = selectedVariant.offer) === null || ref1 === void 0 ? void 0 : ref1.originalPrice
@@ -1,14 +1,3 @@
1
- /**
2
- * Template Options:
3
- * :title: -> is going to be replace with the title
4
- * :name: -> is going to be replace with the name
5
- * :description: -> is going to be replace with the description
6
- * :category: -> is going to be replace with the category
7
- * :price: -> is going to be replace with the price
8
- * :quantity: -> is going to be replace with the quantity
9
- * :brand: -> is going to be replace with the brand
10
- *
11
- */
12
1
  export declare function ProductSEO({ favorTitleTemplateOverMeta, favorDescriptionTemplateOverMeta, titleTemplate, descriptionTemplate, }?: {
13
2
  favorTitleTemplateOverMeta?: boolean;
14
3
  favorDescriptionTemplateOverMeta?: boolean;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sentecacommerce-theme/lib",
3
3
  "sideEffects": false,
4
- "version": "0.13.12",
4
+ "version": "0.13.13",
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": "1b0787f223a54c08f263c5207a6760fb5c9dc81c",
34
+ "gitHead": "daf24e6985c099ac54aaf26c4999a776127c9ad7",
35
35
  "peerDependencies": {
36
36
  "react-query": "^2.26.2"
37
37
  },
38
38
  "dependencies": {
39
- "@sentecacommerce-theme/base": "^0.13.12",
40
- "@sentecacommerce-theme/cms": "^0.13.12",
39
+ "@sentecacommerce-theme/base": "^0.13.13",
40
+ "@sentecacommerce-theme/cms": "^0.13.13",
41
41
  "@sentecacommerce/sdk": "2.0.175",
42
42
  "body-scroll-lock": "^3.1.5",
43
43
  "copy-to-clipboard": "^3.3.1",