mirror of https://github.com/crossplane/docs.git
Added preliminary custom 404 page.
404 page supports redirecting to sensible docs locations. Closes #17
This commit is contained in:
parent
6ace6040ea
commit
cebd4ae10c
|
@ -0,0 +1,39 @@
|
|||
---
|
||||
layout: default
|
||||
permalink: /404.html
|
||||
stylesheet: 404
|
||||
---
|
||||
|
||||
<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>
|
||||
|
||||
<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';
|
||||
|
||||
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>
|
|
@ -4,6 +4,7 @@
|
|||
{% assign currentVersion = url[2] %}
|
||||
{% assign currentVersionPath = '/docs/' | append: currentVersion | append: '/' %}
|
||||
{% assign latestVersion = site.data.versions[0].version %}
|
||||
{% assign filepath = page.url | replace: currentVersionPath %}
|
||||
|
||||
{% include mkhash.inc title = 'Welcome' url = currentVersionPath %}
|
||||
{% assign documents = site.pages | where_exp: 'page', 'page.url contains currentVersionPath' | where: "toc", "true" | sort: 'weight' | unshift: h %}
|
||||
|
@ -21,7 +22,6 @@
|
|||
|
||||
<link rel="stylesheet" href="{{ "/css/main.css" | relative_url }}" />
|
||||
<link rel="stylesheet" href="{{ "/css/docs.css" | relative_url }}" />
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
@ -30,7 +30,7 @@
|
|||
<div>
|
||||
<h1>Documentation</h1>
|
||||
<div class="versions{% if currentVersion == latestVersion %} latest{% endif %}">
|
||||
<div><div><select onchange="window.location.href = this.value">
|
||||
<div><div><select onchange='window.location.href = this.value + {{ filepath | jsonify }}''>
|
||||
{% for ver in site.data.versions %}
|
||||
<option {% if ver.version == currentVersion %}selected{% endif %} value="{{ver.path | append: '/' | relative_url }}">Crossplane {{ ver.version }}</option>
|
||||
{% endfor %}
|
||||
|
@ -99,7 +99,7 @@
|
|||
}
|
||||
|
||||
{% for document in documents %}
|
||||
add({{ document.title | jsonify }}, {{document.url | jsonify }}, {% if document.indent == true %}true{% else %}false{% endif %}, {% if document.url == page.url %}true{% else %}false{% endif %});
|
||||
add({{ document.title | jsonify }}, {{document.url | relative_url | jsonify }}, {% if document.indent == true %}true{% else %}false{% endif %}, {% if document.url == page.url %}true{% else %}false{% endif %});
|
||||
{% endfor %}
|
||||
|
||||
function getEntry(item) {
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
---
|
||||
---
|
||||
h2, h3, #redirect {
|
||||
text-align: center;
|
||||
color: #505a72;
|
||||
}
|
||||
|
||||
#content {
|
||||
#holder {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
display: flex;
|
||||
align-items: center;
|
||||
min-height: calc(100% - 223px);
|
||||
|
||||
a {
|
||||
color: #35d0ba;
|
||||
text-decoration: none;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue