From fa858ac5fa6355594189346d781754d5bc86b5f5 Mon Sep 17 00:00:00 2001 From: Peiran Yao Date: Tue, 23 Jun 2020 15:12:47 -0600 Subject: [PATCH] redirect unavailable help pages to 404 --- _layouts/help.html | 4 ++++ static/js/help.es6 | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/_layouts/help.html b/_layouts/help.html index 2069134..2c2e475 100644 --- a/_layouts/help.html +++ b/_layouts/help.html @@ -12,6 +12,10 @@ {% endif %} + + {% assign help_pages = site.categories["help"] | sort: 'mirrorid' %}
diff --git a/static/js/help.es6 b/static/js/help.es6 index 69f2834..957d559 100644 --- a/static/js/help.es6 +++ b/static/js/help.es6 @@ -39,6 +39,11 @@ $(document).ready(() => { $.getJSON("/static/tunasync.json", (statusData) => { // remove help items for disabled/removed mirrors let availableMirrorIds = new Set(statusData.map(x => x.name)); + console.log(window.mirrorId); + if (!availableMirrorIds.has(window.mirrorId)) { + location.href = "/404.html"; // this will break 404 issue submission + } + $('li').filter((_, node) => node.id && node.id.startsWith("toc-") && !availableMirrorIds.has(node.id.slice(4))).remove(); $('option').filter((_, node) => node.id && node.id.startsWith("toc-") && !availableMirrorIds.has(node.id.slice(4))).remove(); });