Add redirect from old URL to new URL

This commit is contained in:
Steven
2020-08-29 18:46:56 -04:00
parent 9bf1836e00
commit 7846b3da9b
+10 -1
View File
@@ -71,11 +71,20 @@
</div>
</div>
<script>
var match = new RegExp('#/(.+)\.md(.*)', 'g').exec(window.location.hash);
if (match && match[1]) {
// Redirect from URL format to new URL, for example:
// Old: https://marked.js.org/#/USING_PRO.md#renderer
// New: https://marked.js.org/using_pro#renderer
var pageName = match[1].toLowerCase();
var sectionName = match[2];
window.location.href = '/' + pageName + sectionName;
}
var navLinks = document.querySelectorAll('nav a');
function hashChange() {
var fullUrl = window.location.href;
navLinks.forEach(function(link) {
link.className = link.href === fullUrl ? 'selected' : '';
});