Authored by htoooth

fix

... ... @@ -103,6 +103,7 @@ try {
app.get('/pc/sitemap/guang_:id.xml', sitemap.guangXmlData);
app.get('/pc/sitemap/hots_:id.xml', sitemap.hotsXmlData);
app.get('/pc/sitemap/chanpin_:id.xml', sitemap.chanpinXmlData);
app.get('/pc/sitemap/productindex.xml', sitemap.productIndexXmlData);
app.get('/h5/sitemap/sitemapindex.xml', sitemap.indexXmlDataH5);
app.get('/h5/sitemap/sitemapindex.json', sitemap.indexJsonDataH5);
... ... @@ -113,6 +114,7 @@ try {
app.get('/h5/sitemap/guang_:id.xml', sitemap.guangXmlDataH5);
app.get('/h5/sitemap/hots_:id.xml', sitemap.hotsXmlDataH5);
app.get('/h5/sitemap/chanpin_:id.xml', sitemap.chanpinXmlDataH5);
app.get('/h5/sitemap/productindex.xml', sitemap.productIndexXmlDataH5);
} catch (e) {
logger.error(e);
}
... ...
... ... @@ -223,6 +223,24 @@ function indexJsonDataH5(req, res, next) {
.catch(next);
}
function productIndexXmlData(req, res, next) {
req.ctx(SiteMapService).productIndexXml()
.then(xml => {
res.header('Content-Type', 'application/xml');
res.send(xml);
})
.catch(next);
}
function productIndexXmlDataH5(req, res, next) {
req.ctx(SiteMapServiceH5).productIndexXml()
.then(xml => {
res.header('Content-Type', 'application/xml');
res.send(xml);
})
.catch(next);
}
module.exports = {
indexXmlData,
homeXmlData,
... ... @@ -233,6 +251,7 @@ module.exports = {
chanpinXmlData,
hotsXmlData,
indexJsonData,
productIndexXmlData,
indexXmlDataH5,
homeXmlDataH5,
... ... @@ -242,5 +261,6 @@ module.exports = {
guangXmlDataH5,
chanpinXmlDataH5,
hotsXmlDataH5,
indexJsonDataH5
indexJsonDataH5,
productIndexXmlDataH5
};
... ...
... ... @@ -10,7 +10,7 @@ const {
PRIO
} = require('./vars');
module.exports = function ) {
module.exports = function() {
const today = moment().format('Y-M-D');
return {
... ...
... ... @@ -197,4 +197,12 @@ module.exports = class extends global.yoho.BaseModel {
return index.urls.map(url => this.host + url);
}
async productIndexXml() {
const productIndex = await this.productService.getIndex(this.type);
this.config.index.urls = _.concat(this.config.index.urls, productIndex)
return _createSiteMapIndex(this.host, this.config.index);
}
};
... ...
... ... @@ -235,13 +235,13 @@ if (isProduction) {
sitemap: {
pc: {
host: 'https://www.yohobuy.com',
dir: '/Data/doom-spider/sitemap/pc',
dir: '/Data/yoho-seo/sitemap/pc',
type: 'pc',
props: ['lastmod', 'changefreq', 'priority']
},
h5: {
host: 'https://m.yohobuy.com',
dir: '/Data/doom-spider/sitemap/h5',
dir: '/Data/yoho-seo/sitemap/h5',
type: 'h5',
props: ['lastmod', 'changefreq', 'priority', 'mobile']
}
... ...
... ... @@ -59,10 +59,10 @@ class SitemapTask {
fileUrls = JSON.parse(fileUrls);
// let fileUrls = ['https://www.yohobuy.com/sitemap_pc/sitemapindex.xml'];
// let fileUrls = ['https://m.yohobuy.com/sitemap/home_1.xml'];
// let fileUrls = [];
fileUrls.push(`${host}/sitemap_${this.type}/sitemapindex.xml`);
// fileUrls.push(`${host}/sitemap_${this.type}/sitemapindex.xml`);
// fileUrls.push(`${host}/sitemap_${this.type}/productindex.xml`);
await Promise.map(fileUrls, async (url) => {
try {
... ...