Skip to content
Snippets Groups Projects
Commit 4e24b1c7 authored by Luca's avatar Luca
Browse files

Update 404 page for the new format

parent bf2230ae
Branches master
No related tags found
No related merge requests found
Pipeline #150892 passed
...@@ -70,15 +70,15 @@ ...@@ -70,15 +70,15 @@
<script> <script>
async function addFuzzySearch() { async function addFuzzySearch() {
const vanityMap = await (await fetch("/vanitymap.json")).json() const vanityMap = await (await fetch("/vanitymap.json")).json()
const keys = Object.keys(vanityMap); const keys = vanityMap['shortlinks'].map((object) => object.sources).flat(1)
const fuse = new Fuse(keys, {}) const fuse = new Fuse(keys, {})
const pathToSearchFor = window.location.pathname.replace("/", "").replace(".html", "").trim(); const pathToSearchFor = window.location.pathname.replace("/", "").replace(".html", "").trim();
const results = fuse.search(pathToSearchFor) const results = fuse.search(pathToSearchFor)
if (results.length !== 0) { if (results.length !== 0) {
const bestShortlink = results[0].item; const bestShortlink = results[0].item;
const bestHref = vanityMap[bestShortlink]; const bestHref = vanityMap['shortlinks'].filter((object) => object.sources.includes(bestShortlink))[0].destination;
document.getElementById("suggestion-text").innerText = bestShortlink; document.getElementById("suggestion-text").innerText = "/" + bestShortlink;
document.getElementById("suggestion-href").href = bestHref; document.getElementById("suggestion-href").href = bestHref;
document.getElementById("suggestion-section").classList.remove("is-invisible"); document.getElementById("suggestion-section").classList.remove("is-invisible");
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment