Skip to content

Commit

Permalink
Fix URL redirection
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Sep 20, 2019
1 parent 30ec206 commit c97af96
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/docs/assets.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const cpFile = require('cp-file')

const ASSETS = [
`${__dirname}/netlify-logo.png`,
`${__dirname}/assets.js`,
`${__dirname}/script.js`,
`${__dirname}/../../node_modules/analytics/dist/analytics.min.js`,
`${__dirname}/../../node_modules/analytics-plugin-ga/dist/analytics-plugin-ga.min.js`
]
Expand Down
30 changes: 26 additions & 4 deletions src/docs/script.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
/* eslint-env browser */
var Analytics = window._analytics.init({
plugins: [window.analyticsGA({ trackingId: 'UA-42258181-19' })]
})
Analytics.page()
var init = function() {
setupAnalytics()
redirectToNewHash()
}

var setupAnalytics = function() {
var Analytics = window._analytics.init({
plugins: [window.analyticsGA({ trackingId: 'UA-42258181-19' })]
})
Analytics.page()
}

// The previous API documentation used different fragments. We redirect those
// to the new links.
var redirectToNewHash = function() {
var oldHash = OLD_HASH_REGEXP.exec(document.location.hash)
if (oldHash === null) {
return
}

document.location.hash = '#operation/' + oldHash[1]
}

var OLD_HASH_REGEXP = /^#\/default\/(.+)/

init()

0 comments on commit c97af96

Please sign in to comment.