Add a forum redirection page

This is done in the 404 error page as it will match any invalid URL,
including `/forum/viewtopic.php`. We can't create a page with a custom
permalink set to `/forum/viewtopic.php`, as GitHub Pages doesn't set
the MIME type correctly, which causes the browser to download the page.

This closes #187.
master
Hugo Locurcio 2019-09-19 15:33:35 +02:00 committed by sfan5
parent b48b080226
commit db33ce93f1
1 changed files with 11 additions and 0 deletions

View File

@ -5,6 +5,17 @@ layout: default
permalink: 404.html
---
<script>
// Forum URL redirection
const urlParams = new URLSearchParams(window.location.search.slice(1));
if (urlParams.has('id')) {
// Convert to a number for security (only numeric values make sense anyway)
const topicId = Number(urlParams.get('id'));
window.location.replace(`https://forum.minetest.net/viewtopic.php?id=${topicId}`);
}
</script>
<section class="section">
<div class="container">
<div class="content">