summaryrefslogtreecommitdiff
path: root/src/pages/sitemap/brands.xml.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/pages/sitemap/brands.xml.js')
-rw-r--r--src/pages/sitemap/brands.xml.js30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/pages/sitemap/brands.xml.js b/src/pages/sitemap/brands.xml.js
new file mode 100644
index 00000000..7d16bde3
--- /dev/null
+++ b/src/pages/sitemap/brands.xml.js
@@ -0,0 +1,30 @@
+import productSearchApi from '@/lib/product/api/productSearchApi'
+import { create } from 'xmlbuilder'
+import _ from 'lodash-contrib'
+import { createSlug } from '@/core/utils/slug'
+import odooApi from '@/core/api/odooApi'
+
+export async function getServerSideProps({ res }) {
+ const baseUrl = process.env.SELF_HOST + '/shop/brands/'
+ const brands = await odooApi('GET', `/api/v1/manufacture?limit=0`)
+ const sitemap = create('urlset', { encoding: 'UTF-8' })
+
+ const date = new Date()
+ brands.manufactures.forEach((brand) => {
+ const url = sitemap.ele('url')
+ url.ele('loc', createSlug(baseUrl, brand.name, brand.id))
+ url.ele('lastmod', date.toISOString().slice(0, 10))
+ url.ele('changefreq', 'weekly')
+ url.ele('priority', '0.8')
+ })
+
+ res.setHeader('Content-Type', 'text/xml')
+ res.write(sitemap.end())
+ res.end()
+
+ return { props: {} }
+}
+
+export default function SitemapProducts() {
+ return null
+}