base template overrides for 404 page

This commit is contained in:
Pete Lumbis 2022-09-13 17:39:51 -04:00
parent 8dd2e4d2a5
commit 129eb3d0e7
1 changed files with 13 additions and 36 deletions

View File

@ -1,39 +1,16 @@
---
layout: default
permalink: /404.html
stylesheet: 404
---
{{- define "no-robots" -}}
{{- end -}}
<div id="holder">
<h2>404 - Not Found</h2>
<h3>The page you are looking for could not be found.</h3>
<p id="redirect"></p>
</div>
{{- define "title" -}}
{{- .Site.Title -}}
{{- end -}}
<script>
var docsPath = {{ "/docs" | relative_url | jsonify }};
var pagePath = window.location.pathname;
if (pagePath == docsPath || pagePath.startsWith(docsPath + '/')) {
var remainder = pagePath.slice(docsPath.length+1).split('/').filter(function(p) { return p; });
var version = remainder[0];
var timeout = 5000;
var target = docsPath + '/latest';
{{- define "page-style" -}}
<link rel="stylesheet" href="{{ "/css/404.css" | absURL }}" />
{{- end -}}
{{- define "content" -}}
<h2>404 - Not Found</h2>
<h3>The page you are looking for could not be found.</h3>
{{- end -}}
if (remainder.length == 0) {
// Redirect immediately to latest for /docs
window.location = target;
} else {
if (remainder.length == 1) {
// Redirect to latest if they went to a version that does not exist
document.getElementById('redirect').innerHTML = 'In just a moment we\'ll redirect you to the <a href="'+target+'">latest docs</a>.';
} else {
// Redirect to current version root
target = docsPath + '/' + version;
document.getElementById('redirect').innerHTML = 'In just a moment we\'ll redirect you to the main page for the <a href="'+target+'">'+version+' docs</a>.';
}
setTimeout(function () { window.location = target; }, timeout);
}
}
</script>