@lancom/shared 0.0.262 → 0.0.263
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/feeds/google-shopping.js +47 -3
- package/package.json +1 -1
- package/plugins/cache-headers.js +5 -1
package/feeds/google-shopping.js
CHANGED
|
@@ -65,14 +65,13 @@ async function googleShoppingFeed(axios, config, availableStores) {
|
|
|
65
65
|
'g:additional_image_link': images.map(i => ({ _text: i })),
|
|
66
66
|
'g:price': { _text: `${(sp.price || 0)} AUD` },
|
|
67
67
|
'g:availability': { _text: sp.quantityStock > 0 ? 'in_stock' : 'out_of_stock' },
|
|
68
|
-
'g:google_product_category': { _text: 2047 },
|
|
69
|
-
'g:product_type': { _text: `Home > Products > ${product.productType.name}`, },
|
|
68
|
+
'g:google_product_category': { _text: product.feedGoogleProductCategory || 2047 },
|
|
69
|
+
'g:product_type': { _text: product.feedProductType || `Home > Products > ${product.productType.name}`, },
|
|
70
70
|
'g:is_bundle': { _text: product.prePrint ? 'yes' : 'no' },
|
|
71
71
|
'g:identifier_exists': sp.gtin ? 'yes' : 'no',
|
|
72
72
|
'g:product_weight': { _text: `${product.weight} kg` },
|
|
73
73
|
'g:shipping_weight': { _text: `${((product.weight || 0) + (product.weight || 0) * 0.05).toFixed(3)} kg` },
|
|
74
74
|
'g:quantity': { _text: sp.quantityStock },
|
|
75
|
-
|
|
76
75
|
};
|
|
77
76
|
|
|
78
77
|
if (sp.gtin) {
|
|
@@ -101,6 +100,51 @@ async function googleShoppingFeed(axios, config, availableStores) {
|
|
|
101
100
|
info['g:shipping_height'] = { _text: `${product.volume.height} cm` };
|
|
102
101
|
}
|
|
103
102
|
}
|
|
103
|
+
|
|
104
|
+
const productHighlight = `${product.feedProductHighlight || ''}`
|
|
105
|
+
.trim()
|
|
106
|
+
.split(/\n+/g)
|
|
107
|
+
.map(highlight => `${highlight || ''}`.trim())
|
|
108
|
+
.filter(highlight => !!highlight);
|
|
109
|
+
if (productHighlight.length > 0) {
|
|
110
|
+
info['g:product_highlight'] = productHighlight.map(highlight => ({ _text: highlight }));
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if ((product.feedProductDetails || []).length > 0) {
|
|
114
|
+
info['g:product_detail'] = product.feedProductDetails.map(productDetail => {
|
|
115
|
+
const detail = {
|
|
116
|
+
'g:attribute_name': { _text: productDetail.attributeName },
|
|
117
|
+
'g:attribute_value': { _text: productDetail.attributeValue },
|
|
118
|
+
}
|
|
119
|
+
if (productDetail.sectionName) {
|
|
120
|
+
detail['g:section_name'] = productDetail.sectionName;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return detail;
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if ((product.feedCertifications || []).length > 0) {
|
|
128
|
+
info['g:certification'] = product.feedCertifications.map(certification => {
|
|
129
|
+
const detail = {
|
|
130
|
+
'g:certification_authority': { _text: certification.certificationAuthority },
|
|
131
|
+
'g:certification_name': { _text: certification.certificationName },
|
|
132
|
+
'g:certification_code': { _text: certification.certificationCode },
|
|
133
|
+
}
|
|
134
|
+
return detail;
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
for (let label = 0; label <= 4; label++) {
|
|
139
|
+
if (product[`feedCustomLabel${label}`]) {
|
|
140
|
+
info[`custom_label_${label}`] = { _text: product[`feedCustomLabel${label}`] };
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (product.feedLifestyleImage) {
|
|
145
|
+
info['g:lifestyle_image_link'] = { _text: product.feedLifestyleImage };
|
|
146
|
+
}
|
|
147
|
+
|
|
104
148
|
return info;
|
|
105
149
|
})
|
|
106
150
|
];
|
package/package.json
CHANGED
package/plugins/cache-headers.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
module.exports = function (req, res, next) {
|
|
2
2
|
if (!/auth\=/.test(req.headers?.cookie || '')) {
|
|
3
|
-
const
|
|
3
|
+
const routes = [
|
|
4
|
+
/^\/quotes\//,
|
|
5
|
+
/\.xml$/
|
|
6
|
+
];
|
|
7
|
+
const value = routes.some(route => route.test(`${req.url}`)) ? 'no-cache' : `max-age=${31536000}`;
|
|
4
8
|
res.setHeader('Cache-Control', value);
|
|
5
9
|
} else {
|
|
6
10
|
res.setHeader('Cache-Control', 'no-cache');
|