Check upon index page load whether a fragment package name exists, and redirect to package page if so. Closes #4.

This commit is contained in:
Tony Garnock-Jones 2016-08-10 12:22:36 -04:00
parent cd06e7fc87
commit 31bb1312e8
2 changed files with 14 additions and 0 deletions

View File

@ -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)

13
static/index.js Normal file
View File

@ -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;
}
});