Skip to content

Commit 1ab6a4f

Browse files
johndmulhausenLRubin
authored and
LRubin
committed
Fix for .md URLs
1 parent 6051303 commit 1ab6a4f

File tree

1 file changed

+43
-23
lines changed

1 file changed

+43
-23
lines changed

404.md

Lines changed: 43 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,35 @@ permalink: /404.html
55
---
66

77
<script language="JavaScript">
8-
var forwardingURL=window.location.pathname;
9-
if (forwardingURL.charAt(forwardingURL.length - 1) != "/") forwardingURL += "/";
10-
var gonnaFwd = false;
11-
var newURL = "";
12-
var baseURL = "";
13-
console.log(forwardingURL);
14-
{% for item in site.data.docsarchive.docker-compose %}
8+
var forwardingURL=window.location.pathname;
9+
if (forwardingURL.charAt(forwardingURL.length - 1) != "/") forwardingURL += "/";
10+
var gonnaFwd = false;
11+
var newURL = "";
12+
var baseURL = "";
13+
var archive = false;
14+
console.log(forwardingURL);
15+
16+
// .MD EXTENSION CHECK
17+
if (forwardingURL.indexOf(".md") > -1)
18+
{
19+
gonnaFwd = true;
20+
newURL = forwardingURL.replace(".md","");
21+
} else {
22+
23+
// DOCS ARCHIVE CHECK
24+
{% for item in site.data.docsarchive.docker-compose %}
1525
if (forwardingURL.indexOf("/{{ item[0] }}") > -1)
1626
{
1727
console.log("Found via Docker Compose file for Acrhive")
1828
gonnaFwd = true;
29+
archive = true;
1930
// make it so redirects cascade; first, use the base URL, then append path
20-
baseURL = forwardingURL.replace("/{{ item[0] }}","{{ page.archiveserver }}:{{ item[1].ports[0] | replace:':4000','' }}");
21-
forwardingURL = forwardingURL.replace("/{{ item[0] }}/","");
31+
baseURL = "{{ page.archiveserver }}:{{ item[1].ports[0] | replace:':4000','' }}";
32+
newURL = forwardingURL.replace("/{{ item[0] }}","");
2233
}{% endfor %}
34+
35+
if (archive==false) {
36+
// CSV CHECK
2337
{% for item in site.data.redirects %}
2438
var redirectVal = {{ item | jsonify }};
2539
if (forwardingURL == redirectVal.source)
@@ -28,8 +42,10 @@ permalink: /404.html
2842
gonnaFwd = true;
2943
newURL = forwardingURL.replace(redirectVal.source,redirectVal.destination);
3044
}
31-
{% endfor %}
32-
{% for page in site.pages %}{% if page.aliases %}
45+
{% endfor %}
46+
47+
// PAGE ALIASES CHECK
48+
{% for page in site.pages %}{% if page.aliases %}
3349
var aliases = {{ page.aliases | jsonify }};
3450
if( Object.prototype.toString.call( aliases ) === '[object Array]' ) {
3551
// aliases is an array, therefore, there are multiple aliases
@@ -51,16 +67,20 @@ permalink: /404.html
5167
newURL = "{{ page.url }}";
5268
}
5369
}
54-
{% endif %}{% endfor %}
55-
if (gonnaFwd) {
56-
newURL = baseURL + newURL;
57-
console.log("Forwarding to: " + newURL);
58-
window.location.replace(newURL);
59-
window.location.href = newURL;
60-
document.write('<meta http-equiv="refresh" content="0; url=' + newURL + '">')
61-
} else {
62-
window.location.replace("/sorry/#" + forwardingURL);
63-
window.location.href = "/sorry/#" + forwardingURL;
64-
document.write('<meta http-equiv="refresh" content="0; url=/sorry/#' + forwardingURL + '">')
65-
}
70+
{% endif %}{% endfor %}
71+
72+
} // end of check for .md
73+
} // end of check for archive
74+
75+
if (gonnaFwd) {
76+
newURL = baseURL + newURL;
77+
console.log("Forwarding to: " + newURL);
78+
window.location.replace(newURL);
79+
window.location.href = newURL;
80+
document.write('<meta http-equiv="refresh" content="0; url=' + newURL + '">')
81+
} else {
82+
window.location.replace("/sorry/#" + forwardingURL);
83+
window.location.href = "/sorry/#" + forwardingURL;
84+
document.write('<meta http-equiv="refresh" content="0; url=/sorry/#' + forwardingURL + '">')
85+
}
6686
</script>

0 commit comments

Comments
 (0)