From 9fd1c9ad27a5735046944623216481e5564abb78 Mon Sep 17 00:00:00 2001 From: John Mulhausen Date: Wed, 5 Oct 2016 14:05:37 -0700 Subject: [PATCH] Add forwarding for page aliases --- 404.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/404.md b/404.md index ee36caed4f..e3329eb792 100644 --- a/404.md +++ b/404.md @@ -11,6 +11,30 @@ function doFwd() { var portNumber = window.location.port; var gonnaFwd = false; var newURL = ""; + console.log(forwardingURL); + {% for page in site.pages %}{% if page.aliases %} + var aliases = {{ page.aliases | jsonify }}; + if( Object.prototype.toString.call( aliases ) === '[object Array]' ) { + // aliases is an array, therefore, there are multiple aliases + for (i=0; i< aliases.length; i++) + { + if (forwardingURL.indexOf(aliases[i]) > -1) + { + console.log("Found! ", forwardingURL.indexOf(aliases[i]), aliases[i]) + gonnaFwd = true; + newURL = "{{ page.url }}"; + } + } + } else { + // only one alias for this page. + if (forwardingURL.indexOf(aliases) > -1) + { + console.log("Found! ", forwardingURL.indexOf(aliases[i]), aliases[i]) + gonnaFwd = true; + newURL = "{{ page.url }}"; + } + } + {% endif %}{% endfor %} {% for item in site.data.docsarchive.docker-compose %} if (forwardingURL.indexOf("/{{ item[0] }}") > -1) {