@lancom/shared 0.0.380 → 0.0.382

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.
@@ -38,8 +38,8 @@ const api = {
38
38
  fetchCustomerOrders(customer, shop) {
39
39
  return _get(`shop/${shop}/customer/${customer._id}/orders`);
40
40
  },
41
- searchProducts(shop, text) {
42
- return _get(`shop/${shop}/products/search`, { text });
41
+ searchProducts(shop, text, save) {
42
+ return _get(`shop/${shop}/products/search`, { text, save });
43
43
  },
44
44
  fetchProducts(shop, params) {
45
45
  return _get(`shop/${shop}/products`, params);
@@ -117,6 +117,9 @@ export default {
117
117
  type: Boolean,
118
118
  default: false
119
119
  },
120
+ postcodesRange: {
121
+ type: String
122
+ },
120
123
  disabled: {
121
124
  type: Boolean,
122
125
  default: false
@@ -168,12 +171,13 @@ export default {
168
171
  }
169
172
  },
170
173
  methods: {
171
- async handleSearch(query) {
174
+ async handleSearch(query = '') {
172
175
  if (query.trim().length > 1) {
173
176
  this.isLoading = true;
174
177
  const country = this.codeCountry || this.country;
175
178
  const countryName = country ? (['GB','UK'].includes(country.isoCode) ? 'UK' : (country.name || country)) : 'Australia';
176
179
  const params = {
180
+ postcode: this.postcodesRange,
177
181
  query: query.trim(),
178
182
  country: countryName
179
183
  };
@@ -118,7 +118,7 @@ export default {
118
118
  });
119
119
  }
120
120
  try {
121
- this.products = this.text ? await api.searchProducts(this.shop._id, this.text) : [];
121
+ this.products = this.text ? await api.searchProducts(this.shop._id, this.text, true) : [];
122
122
  } catch (e) {
123
123
  this.products = [];
124
124
  } finally {
@@ -105,6 +105,16 @@
105
105
  const page = +this.$route.query.page;
106
106
  return `${this.breadcrumbs[this.breadcrumbs.length - 1]?.to}${page > 1 ? `?page=${page}` : ''}`;
107
107
  },
108
+ pageItemType() {
109
+ return 'product';
110
+ },
111
+ pageItemImage() {
112
+ const images = this.products.reduce((images, product) => {
113
+ const image = getProductLargeCover(product, 'front') || getProductMediumCover(product, 'front');
114
+ return image ? [...images, image] : images;
115
+ }, []);
116
+ return images.slice(0, 1);
117
+ },
108
118
  currentBrand() {
109
119
  return this.findByRouteParam(this.brands, 'brand');
110
120
  },
@@ -51,6 +51,10 @@ const metaInfo = {
51
51
  hid: 'og:title',
52
52
  property: 'og:title',
53
53
  content: pageTitle
54
+ }, {
55
+ hid: 'og:type',
56
+ property: 'og:type',
57
+ content: this.pageItemType || 'website'
54
58
  }];
55
59
 
56
60
  const canonical = this.getCanonical();
@@ -91,23 +95,26 @@ const metaInfo = {
91
95
  });
92
96
  }
93
97
 
94
- const pageImage = this.pageItemImage || this.pageItem?.image || (this.pageItem?.images && this.pageItem?.images[0]) || image;
98
+ const pageImage = this.pageItemImage || this.pageItem?.image || (this.pageItem?.images?.length > 0 && this.pageItem?.images) || image;
95
99
  if (pageImage) {
96
- const pageImageUrl = staticLink(typeof pageImage === 'string' ? pageImage : (pageImage.medium || pageImage.large));
97
- metaTags.push({
98
- hid: 'og:image',
99
- property: 'og:image',
100
- content: pageImageUrl
101
- });
102
-
103
- link.push({
104
- hid: 'preloadImage',
105
- rel: 'preload',
106
- fetchpriority: 'high',
107
- as: 'image',
108
- type: 'image/webp',
109
- href: pageImageUrl
110
- });
100
+ const pageImages = Array.isArray(pageImage) ? pageImage : [pageImage];
101
+ for (const image of pageImages) {
102
+ const pageImageUrl = staticLink(typeof image === 'string' ? image : (image.medium || image.large));
103
+ metaTags.push({
104
+ hid: 'og:image',
105
+ property: 'og:image',
106
+ content: pageImageUrl
107
+ });
108
+
109
+ link.push({
110
+ hid: 'preloadImage',
111
+ rel: 'preload',
112
+ fetchpriority: 'high',
113
+ as: 'image',
114
+ type: 'image/webp',
115
+ href: pageImageUrl
116
+ });
117
+ }
111
118
  }
112
119
 
113
120
  const pageTags = pageItemMeta?.tags?.length > 0 ? pageItemMeta.tags : meta.tags;
@@ -94,6 +94,9 @@ export default (IS_PRODUCT_PRESET_PRINT_PRICING, isEditor = false) => ({
94
94
  stockCountryId() {
95
95
  return this.stockCountry?._id || null;
96
96
  },
97
+ pageItemType() {
98
+ return 'product';
99
+ },
97
100
  pageItemImage() {
98
101
  return this.mainProductImageSrc;
99
102
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lancom/shared",
3
- "version": "0.0.380",
3
+ "version": "0.0.382",
4
4
  "description": "lancom common scripts",
5
5
  "author": "e.tokovenko <e.tokovenko@gmail.com>",
6
6
  "repository": {
@@ -39,6 +39,11 @@ export default {
39
39
  openedGroup: this.$route.params.group,
40
40
  openedEntity: this.$route.query.id
41
41
  };
42
+ },
43
+ computed: {
44
+ pageItemType() {
45
+ return 'article';
46
+ }
42
47
  }
43
48
  };
44
49
  </script>
@@ -30,6 +30,11 @@ export default {
30
30
  openedGroup: this.$route.query.group,
31
31
  openedEntity: this.$route.query.id
32
32
  };
33
+ },
34
+ computed: {
35
+ pageItemType() {
36
+ return 'article';
37
+ }
33
38
  }
34
39
  };
35
40
  </script>
@@ -59,6 +59,9 @@ export default {
59
59
  to: '/news',
60
60
  text: 'Blog'
61
61
  }, item].filter(i => !!i);
62
+ },
63
+ pageItemType() {
64
+ return 'article';
62
65
  }
63
66
  },
64
67
  getRoute() {
@@ -41,6 +41,11 @@ export default {
41
41
  text: 'Blog'
42
42
  }]
43
43
  };
44
+ },
45
+ computed: {
46
+ pageItemType() {
47
+ return 'article';
48
+ }
44
49
  }
45
50
  };
46
51
  </script>
@@ -49,6 +49,9 @@ export default {
49
49
  }, {
50
50
  text: this.pageItem.title
51
51
  }];
52
+ },
53
+ pageItemType() {
54
+ return 'article';
52
55
  }
53
56
  }
54
57
  };