Move 404 script to 404 page, and improve link-generation

If we found a "referer" address, the body now contains the URL from which we
arrived at the 404. For example;

https://github.com/docker/docker.github.io/issues/new?title=404+at+%2Fnosuchpage&body=I+found+a+broken+link+%3A+https%3A%2F%2Fdocs.docker.com%2Fnosuchpage%0AI+arrived+on+this+page+through%3A+https%3A%2F%2Fdocs.docker.com%2Fregistry%2Fspec%2Fapi%2F

Which opens a new ticket:

    Title: 404 at /nosuchpage

    I found a broken link : https://docs.docker.com/nosuchpage
    I arrived on this page through: https://docs.docker.com/registry/spec/api/

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2020-10-09 00:42:33 +02:00
parent 2993c55840
commit 389f5d14d0
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
2 changed files with 20 additions and 15 deletions

24
404.md
View File

@ -7,10 +7,26 @@ skip_read_time: true
---
There might be a mistake in the URL or you might've clicked a link to content
that no longer exists.
If you think it's the latter, please file an issue at [https://github.com/docker/docker.github.io](https://github.com/docker/docker.github.io/issues/new)
that no longer exists. If you think it's the latter, please file an issue in
our [issue tracker on GitHub](https://github.com/docker/docker.github.io/issues/new)
and let us know what happened. Please also include a link to where the error
occurred, if applicable.
![https://docs.docker.com/](/images/404-docs.png)
[**Click here to create a new ticket**](https://github.com/docker/docker.github.io/issues/new){:.newissue.button.primary-btn}
[![404 page not found](/images/404-docs.png)](https://docs.docker.com/ "Go to the homepage")
<script>
let el = document.querySelector("a.newissue");
if (el) {
let url = new URL("https://github.com/docker/docker.github.io/issues/new");
url.searchParams.set("title", "404 at " + window.location.pathname);
let body = "I found a broken link : " + window.location.href;
if (document.referrer !== "") {
body += "\nI arrived on this page through: " + document.referrer
}
url.searchParams.set("body", body);
el.setAttribute("href", url.toString());
}
</script>

View File

@ -89,17 +89,6 @@
</div>
</div>
</div>
{% if page.path == "404.md" %}
<script>
var path = window.location.pathname.replace("#", "");
var ghIssueQueryString = "https://github.com/docker/docker.github.io/issues/new?" + "title=404%20at%20" + path + "&body=URL%3A%20" + path;
document.getElementsByClassName("nomunge")[1].onclick = function () {
document.getElementsByClassName("nomunge")[1].href = ghIssueQueryString;
return true;
};
</script>
{% endif %}
<footer class="footer">
{% include footer.html %}
</footer>