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 @@
--- {{- define "no-robots" -}}
layout: default {{- end -}}
permalink: /404.html
stylesheet: 404
---
<div id="holder"> {{- define "title" -}}
<h2>404 - Not Found</h2> {{- .Site.Title -}}
<h3>The page you are looking for could not be found.</h3> {{- end -}}
<p id="redirect"></p>
</div>
<script> {{- define "page-style" -}}
var docsPath = {{ "/docs" | relative_url | jsonify }}; <link rel="stylesheet" href="{{ "/css/404.css" | absURL }}" />
var pagePath = window.location.pathname; {{- end -}}
{{- define "content" -}}
if (pagePath == docsPath || pagePath.startsWith(docsPath + '/')) { <h2>404 - Not Found</h2>
var remainder = pagePath.slice(docsPath.length+1).split('/').filter(function(p) { return p; }); <h3>The page you are looking for could not be found.</h3>
var version = remainder[0]; {{- end -}}
var timeout = 5000;
var target = docsPath + '/latest';
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>