Skip to content

Commit 46227af

Browse files
authored
Oddk/sitemap (#74)
1 parent 405ce63 commit 46227af

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

index.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -284,11 +284,9 @@ module.exports = function (app) {
284284
const robotsTxt = fs.readFileSync(robotsPath, 'utf8')
285285

286286
if (!robotsTxt.includes('Sitemap:')) {
287-
const hostname = 'https://' + req.get('host')
287+
const hostname = config.get('SITE_URL')
288288
const sitemapUrl = hostname + '/sitemap.xml'
289-
const wwwHostname = hostname.replace('://', '://www.')
290-
const wwwSitemapUrl = wwwHostname + '/sitemap.xml'
291-
const robotsTxtWithSitemap = robotsTxt + '\nUser-agent: *\nSitemap: ' + sitemapUrl + '\nSitemap: ' + wwwSitemapUrl
289+
const robotsTxtWithSitemap = robotsTxt + '\nUser-agent: *\nSitemap: ' + sitemapUrl
292290

293291
fs.writeFileSync(robotsPath, robotsTxtWithSitemap)
294292
}
@@ -304,7 +302,7 @@ module.exports = function (app) {
304302
res.header('Content-Type', 'application/xml');
305303
res.header('Content-Encoding', 'gzip');
306304

307-
const hostname = 'https://' + req.get('host')
305+
const hostname = config.get('SITE_URL')
308306

309307
try {
310308
const smStream = new SitemapStream({ hostname: hostname })
@@ -319,7 +317,7 @@ module.exports = function (app) {
319317

320318
for (let collection of collectionsArray) {
321319
smStream.write({
322-
url: `/collection/${collection.name}`,
320+
url: `/collections/${collection.name}`,
323321
img: collection.image
324322
})
325323
}
@@ -330,7 +328,7 @@ module.exports = function (app) {
330328

331329
for (let organization of organizationsArray) {
332330
smStream.write({
333-
url: `/organization/${organization.name}`,
331+
url: `/${organization.name}`,
334332
img: organization.image
335333
})
336334
}

0 commit comments

Comments
 (0)