@lancom/shared 0.0.63 → 0.0.64

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.
Files changed (2) hide show
  1. package/nuxt.config.js +44 -3
  2. package/package.json +1 -1
package/nuxt.config.js CHANGED
@@ -31,7 +31,7 @@ module.exports = (config, axios) => ({
31
31
  '/customer/**'
32
32
  ],
33
33
  routes: async () => {
34
- const { data } = await axios.get(`${config.API_URL}/sitemap?host=${config.HOST_NAME}`);
34
+ const { data } = await axios.get(`${config.API_URL}/feed/sitemap?host=${config.HOST_NAME}`);
35
35
  return data.map(url => ({ url, priority: 0.8 }));
36
36
  }
37
37
  },
@@ -56,7 +56,8 @@ module.exports = (config, axios) => ({
56
56
  modules: [
57
57
  '@nuxtjs/axios',
58
58
  '@nuxtjs/dotenv',
59
- '@nuxtjs/sitemap'
59
+ '@nuxtjs/sitemap',
60
+ '@/node_modules/@lancom/feed/lib/module'
60
61
  ],
61
62
  axios: {
62
63
  },
@@ -71,5 +72,45 @@ module.exports = (config, axios) => ({
71
72
  '@lancom'
72
73
  ],
73
74
  extend(config, ctx) {}
74
- }
75
+ },
76
+ feed: [{
77
+ path: '/google-shopping.xml',
78
+ async get() {
79
+ const { data } = await axios.get(`${config.API_URL}/feed/products?host=${config.HOST_NAME}`);
80
+ return {
81
+ title: { _text: 'All products' },
82
+ link: { _text: `https://${config.HOST_NAME}` },
83
+ generator: { _text: config.HOST_NAME },
84
+ item: data.map(item => {
85
+ const spliceFirstImage = images => (images || []).splice(0, 1)[0];
86
+ const getImages = images => (images || []).length > 0 ? images : null;
87
+ const image = spliceFirstImage(item.colorImages) || spliceFirstImage(item.frontImages) || spliceFirstImage(item.backImages) || {};
88
+ const images = getImages(item.colorImages) || getImages(item.frontImages) || getImages(item.backImages) || [];
89
+ return {
90
+ title: { _text: `${item.name} ${item.color}-${item.size}` },
91
+ link: { _text: `https://${config.HOST_NAME}${item.link}` },
92
+ 'g:id': { _text: item.id },
93
+ 'g:item_group_id': { _text: item.groupId },
94
+ 'g:size': { _text: item.size },
95
+ 'g:size_system': 'AU',
96
+ 'g:size_type': 'regular',
97
+ 'g:gender': { _text: item.gender },
98
+ 'g:material': { _text: item.naterial },
99
+ 'g:brand': { _text: item.brand },
100
+ 'g:condition': { _text: item.condition },
101
+ 'g:mpn': { _text: item.mpn },
102
+ 'g:color': { _text: item.color },
103
+ 'g:image_link': image.medium,
104
+ 'g:additional_image_link': images.map(i => i.medium),
105
+ // 'g:google_product_category': 'Business & Industrial>Work Safety Protective Equipment>High-Visibility Clothing',
106
+ // 'g:product_type': 'WDP AU ROOT > Day Night Safety Vests',
107
+ // 'g:availability': 'in stock',
108
+ // 'g:price': '5.49AUD',
109
+ // 'g:identifier_exists': true,
110
+ // 'g:shipping_weight': { _text: item.weight }
111
+ };
112
+ })
113
+ };
114
+ }
115
+ }]
75
116
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lancom/shared",
3
- "version": "0.0.63",
3
+ "version": "0.0.64",
4
4
  "description": "lancom common scripts",
5
5
  "author": "e.tokovenko <e.tokovenko@gmail.com>",
6
6
  "repository": {