summaryrefslogtreecommitdiff
path: root/src/pages
diff options
context:
space:
mode:
Diffstat (limited to 'src/pages')
-rw-r--r--src/pages/google_merchant/products/[page].js15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/pages/google_merchant/products/[page].js b/src/pages/google_merchant/products/[page].js
index 7db826bb..aaa4dde4 100644
--- a/src/pages/google_merchant/products/[page].js
+++ b/src/pages/google_merchant/products/[page].js
@@ -24,14 +24,21 @@ export async function getServerSideProps({ res, query }) {
products.response.products.forEach((product) => {
const productUrl = createSlug('/shop/product/', product.name, product.id, true)
const productId = product.code != '' ? product.code : product.id
- const productDescription = product.description?.replace(/<[^>]*>/g, ' ') || ''
+ const regexHtmlTags = /(<([^>]+)>)/gi
+ product.description = product.description?.replace(regexHtmlTags, ' ').trim()
+ const defaultProductDescription =
+ 'Indoteknik.com menawarkan berbagai produk industri, konstruksi, dan teknik terpercaya. Temukan mesin industri, peralatan listrik, alat pengukur, dan banyak lagi. Pengalaman berbelanja mudah dengan deskripsi produk lengkap, spesifikasi teknis, dan gambar jelas. Pembayaran aman, pengiriman cepat ke seluruh Indonesia. Solusi lengkap untuk kebutuhan Kantor, Industri & Teknik Anda.'
+
+ if (!product.description) {
+ product.description = defaultProductDescription
+ }
const item = {
'g:id': { '#text': productId },
- 'g:title': { '#text': `<![CDATA[${toTitleCase(product.name)}]]>` },
- 'g:description': { '#text': `<![CDATA[${productDescription}]]>` },
+ 'g:title': { '#text': toTitleCase(product.name) },
+ 'g:description': { '#text': product.description },
'g:link': { '#text': productUrl },
- 'g:image': { '#text': product.image },
+ 'g:image_link': { '#text': product.image },
'g:condition': { '#text': 'new' },
'g:availability': { '#text': 'in_stock' },
'g:brand': { '#text': product.manufacture?.name || '' },