Skip to content

Commit

Permalink
allow search indexing in promo mode
Browse files Browse the repository at this point in the history
  • Loading branch information
joelanman committed Jan 30, 2017
1 parent 99b145d commit 4d53696
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,24 +111,31 @@ app.locals.promoMode = promoMode
app.locals.releaseVersion = 'v' + releaseVersion
app.locals.serviceName = config.serviceName

// Disallow search index idexing
app.use(function (req, res, next) {
// Setting headers stops pages being indexed even if indexed pages link to them.
res.setHeader('X-Robots-Tag', 'noindex')
next()
})

app.get('/robots.txt', function (req, res) {
res.type('text/plain')
res.send('User-agent: *\nDisallow: /')
})

// Redirect root to /docs when in promo mode.
if (promoMode === 'true') {
console.log('Prototype kit running in promo mode')

app.get('/', function (req, res) {
res.redirect('/docs')
})

// allow search engines to index the prototype kit promo site
app.get('/robots.txt', function (req, res) {
res.type('text/plain')
res.send('User-agent: *\nAllow: /')
})
} else {
// Disallow search index idexing
app.use(function (req, res, next) {
// Setting headers stops pages being indexed even if indexed pages link to them.
res.setHeader('X-Robots-Tag', 'noindex')
next()
})

app.get('/robots.txt', function (req, res) {
res.type('text/plain')
res.send('User-agent: *\nDisallow: /')
})
}

// routes (found in app/routes.js)
Expand Down

0 comments on commit 4d53696

Please sign in to comment.