Showing
6 changed files
with
37 additions
and
7 deletions
@@ -103,6 +103,7 @@ try { | @@ -103,6 +103,7 @@ try { | ||
103 | app.get('/pc/sitemap/guang_:id.xml', sitemap.guangXmlData); | 103 | app.get('/pc/sitemap/guang_:id.xml', sitemap.guangXmlData); |
104 | app.get('/pc/sitemap/hots_:id.xml', sitemap.hotsXmlData); | 104 | app.get('/pc/sitemap/hots_:id.xml', sitemap.hotsXmlData); |
105 | app.get('/pc/sitemap/chanpin_:id.xml', sitemap.chanpinXmlData); | 105 | app.get('/pc/sitemap/chanpin_:id.xml', sitemap.chanpinXmlData); |
106 | + app.get('/pc/sitemap/productindex.xml', sitemap.productIndexXmlData); | ||
106 | 107 | ||
107 | app.get('/h5/sitemap/sitemapindex.xml', sitemap.indexXmlDataH5); | 108 | app.get('/h5/sitemap/sitemapindex.xml', sitemap.indexXmlDataH5); |
108 | app.get('/h5/sitemap/sitemapindex.json', sitemap.indexJsonDataH5); | 109 | app.get('/h5/sitemap/sitemapindex.json', sitemap.indexJsonDataH5); |
@@ -113,6 +114,7 @@ try { | @@ -113,6 +114,7 @@ try { | ||
113 | app.get('/h5/sitemap/guang_:id.xml', sitemap.guangXmlDataH5); | 114 | app.get('/h5/sitemap/guang_:id.xml', sitemap.guangXmlDataH5); |
114 | app.get('/h5/sitemap/hots_:id.xml', sitemap.hotsXmlDataH5); | 115 | app.get('/h5/sitemap/hots_:id.xml', sitemap.hotsXmlDataH5); |
115 | app.get('/h5/sitemap/chanpin_:id.xml', sitemap.chanpinXmlDataH5); | 116 | app.get('/h5/sitemap/chanpin_:id.xml', sitemap.chanpinXmlDataH5); |
117 | + app.get('/h5/sitemap/productindex.xml', sitemap.productIndexXmlDataH5); | ||
116 | } catch (e) { | 118 | } catch (e) { |
117 | logger.error(e); | 119 | logger.error(e); |
118 | } | 120 | } |
@@ -223,6 +223,24 @@ function indexJsonDataH5(req, res, next) { | @@ -223,6 +223,24 @@ function indexJsonDataH5(req, res, next) { | ||
223 | .catch(next); | 223 | .catch(next); |
224 | } | 224 | } |
225 | 225 | ||
226 | +function productIndexXmlData(req, res, next) { | ||
227 | + req.ctx(SiteMapService).productIndexXml() | ||
228 | + .then(xml => { | ||
229 | + res.header('Content-Type', 'application/xml'); | ||
230 | + res.send(xml); | ||
231 | + }) | ||
232 | + .catch(next); | ||
233 | +} | ||
234 | + | ||
235 | +function productIndexXmlDataH5(req, res, next) { | ||
236 | + req.ctx(SiteMapServiceH5).productIndexXml() | ||
237 | + .then(xml => { | ||
238 | + res.header('Content-Type', 'application/xml'); | ||
239 | + res.send(xml); | ||
240 | + }) | ||
241 | + .catch(next); | ||
242 | +} | ||
243 | + | ||
226 | module.exports = { | 244 | module.exports = { |
227 | indexXmlData, | 245 | indexXmlData, |
228 | homeXmlData, | 246 | homeXmlData, |
@@ -233,6 +251,7 @@ module.exports = { | @@ -233,6 +251,7 @@ module.exports = { | ||
233 | chanpinXmlData, | 251 | chanpinXmlData, |
234 | hotsXmlData, | 252 | hotsXmlData, |
235 | indexJsonData, | 253 | indexJsonData, |
254 | + productIndexXmlData, | ||
236 | 255 | ||
237 | indexXmlDataH5, | 256 | indexXmlDataH5, |
238 | homeXmlDataH5, | 257 | homeXmlDataH5, |
@@ -242,5 +261,6 @@ module.exports = { | @@ -242,5 +261,6 @@ module.exports = { | ||
242 | guangXmlDataH5, | 261 | guangXmlDataH5, |
243 | chanpinXmlDataH5, | 262 | chanpinXmlDataH5, |
244 | hotsXmlDataH5, | 263 | hotsXmlDataH5, |
245 | - indexJsonDataH5 | 264 | + indexJsonDataH5, |
265 | + productIndexXmlDataH5 | ||
246 | }; | 266 | }; |
@@ -10,7 +10,7 @@ const { | @@ -10,7 +10,7 @@ const { | ||
10 | PRIO | 10 | PRIO |
11 | } = require('./vars'); | 11 | } = require('./vars'); |
12 | 12 | ||
13 | -module.exports = function ) { | 13 | +module.exports = function() { |
14 | const today = moment().format('Y-M-D'); | 14 | const today = moment().format('Y-M-D'); |
15 | 15 | ||
16 | return { | 16 | return { |
@@ -197,4 +197,12 @@ module.exports = class extends global.yoho.BaseModel { | @@ -197,4 +197,12 @@ module.exports = class extends global.yoho.BaseModel { | ||
197 | 197 | ||
198 | return index.urls.map(url => this.host + url); | 198 | return index.urls.map(url => this.host + url); |
199 | } | 199 | } |
200 | + | ||
201 | + async productIndexXml() { | ||
202 | + const productIndex = await this.productService.getIndex(this.type); | ||
203 | + | ||
204 | + this.config.index.urls = _.concat(this.config.index.urls, productIndex) | ||
205 | + | ||
206 | + return _createSiteMapIndex(this.host, this.config.index); | ||
207 | + } | ||
200 | }; | 208 | }; |
@@ -235,13 +235,13 @@ if (isProduction) { | @@ -235,13 +235,13 @@ if (isProduction) { | ||
235 | sitemap: { | 235 | sitemap: { |
236 | pc: { | 236 | pc: { |
237 | host: 'https://www.yohobuy.com', | 237 | host: 'https://www.yohobuy.com', |
238 | - dir: '/Data/doom-spider/sitemap/pc', | 238 | + dir: '/Data/yoho-seo/sitemap/pc', |
239 | type: 'pc', | 239 | type: 'pc', |
240 | props: ['lastmod', 'changefreq', 'priority'] | 240 | props: ['lastmod', 'changefreq', 'priority'] |
241 | }, | 241 | }, |
242 | h5: { | 242 | h5: { |
243 | host: 'https://m.yohobuy.com', | 243 | host: 'https://m.yohobuy.com', |
244 | - dir: '/Data/doom-spider/sitemap/h5', | 244 | + dir: '/Data/yoho-seo/sitemap/h5', |
245 | type: 'h5', | 245 | type: 'h5', |
246 | props: ['lastmod', 'changefreq', 'priority', 'mobile'] | 246 | props: ['lastmod', 'changefreq', 'priority', 'mobile'] |
247 | } | 247 | } |
@@ -59,10 +59,10 @@ class SitemapTask { | @@ -59,10 +59,10 @@ class SitemapTask { | ||
59 | 59 | ||
60 | fileUrls = JSON.parse(fileUrls); | 60 | fileUrls = JSON.parse(fileUrls); |
61 | 61 | ||
62 | - // let fileUrls = ['https://www.yohobuy.com/sitemap_pc/sitemapindex.xml']; | ||
63 | - // let fileUrls = ['https://m.yohobuy.com/sitemap/home_1.xml']; | 62 | + // let fileUrls = []; |
64 | 63 | ||
65 | - fileUrls.push(`${host}/sitemap_${this.type}/sitemapindex.xml`); | 64 | + // fileUrls.push(`${host}/sitemap_${this.type}/sitemapindex.xml`); |
65 | + // fileUrls.push(`${host}/sitemap_${this.type}/productindex.xml`); | ||
66 | 66 | ||
67 | await Promise.map(fileUrls, async (url) => { | 67 | await Promise.map(fileUrls, async (url) => { |
68 | try { | 68 | try { |
-
Please register or login to post a comment