Skip to content

Commit

Permalink
Point to latest release if not in ‘promo mode’
Browse files Browse the repository at this point in the history
Now that we’re relying on the version defined in package.json, it will only ever link to the same version as used by the copy of the kit, not the actual latest version. This is fine for the docs site on Heroku, which should always be running the latest version, but could cause issues if someone tries to download the latest version by using the docs running locally in their kit.

When the kit is not running in ‘promo mode’ (as used by the live docs site), just point the user to the latest release page on GitHub.
  • Loading branch information
36degrees committed Nov 2, 2020
1 parent dbbd14a commit 1113292
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions docs/documentation_routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,24 @@ router.get('/install/:page', function (req, res) {
res.render('install_template', { document: html })
})

// Redirect to download the current release zip from GitHub, based on the
// version number from package.json
// When in 'promo mode', redirect to download the current release zip from
// GitHub, based on the version number from package.json
//
// Otherwise, redirect to the latest release page on GitHub, to avoid just
// linking to the same version being run by someone referring to the copy of the
// docs running in their kit
router.get('/download', function (req, res) {
const version = require('../package.json').version
if (req.app.locals.promoMode === 'true') {
const version = require('../package.json').version

res.redirect(
`https://github.com/alphagov/govuk-prototype-kit/archive/v${version}.zip`
)
res.redirect(
`https://github.com/alphagov/govuk-prototype-kit/archive/v${version}.zip`
)
} else {
res.redirect(
'https://github.com/alphagov/govuk-prototype-kit/releases/latest'
)
}
})

// Examples - examples post here
Expand Down

0 comments on commit 1113292

Please sign in to comment.