diff --git a/src/site.rkt b/src/site.rkt index 0770cc5..755a096 100644 --- a/src/site.rkt +++ b/src/site.rkt @@ -152,6 +152,7 @@ dynamic-static-urlprefix)) (bootstrap-dynamic-urlprefix dynamic-urlprefix) + (bootstrap-page-scripts (list (static-resource-url "/index.js"))) (bootstrap-inline-js (string-append (format "PkgSiteDynamicBaseUrl = '~a';" dynamic-urlprefix) (format "PkgSiteStaticBaseUrl = '~a';" static-urlprefix) diff --git a/static/index.js b/static/index.js new file mode 100644 index 0000000..c3993e2 --- /dev/null +++ b/static/index.js @@ -0,0 +1,13 @@ +"use strict"; + +$(document).ready(function () { + // "Cool URLs Don't Break" - catch uses of fragment-based links to + // specific packages, and effectively redirect to the new-style + // specific package URL. + // + var oldstyle_link = document.location.hash.match(/#\[(.*)\]$/); + if (oldstyle_link) { + var linked_package = oldstyle_link[1]; + document.location = document.location.pathname + 'package/' + linked_package; + } +});