Skip to content

Commit 07607fa

Browse files
Make 404 friendlier
Update the 404 page to use some undocumented features of the GitHub "create page" feature to automatically provide the right filename and a template.
1 parent b6da9b5 commit 07607fa

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

message-index/404.html

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,18 @@
88
const messageRe = /^\/messages\/([A-Za-z]+-[0-9]+)/;
99
if (messageRe.test(window.location.pathname)) {
1010
const messageNum = window.location.pathname.match(messageRe)[1];
11-
document.getElementById("documentation-pointer").innerHTML = "Message <code>" + messageNum + "</code> is currently undocumented. You can help out by <a href=\"https://github.com/haskellfoundation/error-message-index/issues?q=is%3Aissue+is%3Aopen+" + messageNum + "\">opening or commenting on an issue</a> or <a href=\"https://github.com/haskellfoundation/error-message-index/blob/main/CONTRIBUTING.md\">contributing documentation</a>."
11+
12+
const ghcSince = "9.6.1";
13+
const otherSince = "VERSION%20IN%20WHICH%20THE%20ERROR%20CODE%20WAS%20INTRODUCED";
14+
const since = messageNum.substring(0, 4) == "GHC-" ? ghcSince : otherSince;
15+
const defaultContents = "---%0Atitle%3A%20SHORT%20TITLE%0Asummary%3A%20ONE%20SENTENCE%20SUMMARY%0Aintroduced%3A%20" + since + "%0Aseverity%3A%20CHOOSE%20ONE%3A%20warning%20error%0A---%0A%0APlease%20describe%20the%20meaning%20of%20the%20error%20here%2C%20formatted%20in%20Markdown.";
16+
const contribURL = "https://github.com/haskellfoundation/error-message-index/new/main/message-index/messages/" + messageNum + "/new?filename=index.md&value=" + defaultContents;
17+
18+
const firstPara = "<p>Message <code>" + messageNum + "</code> is not yet documented here.</p>";
19+
const secondPara "<p>You can help out by documenting it. There are two ways to get started:</p>";
20+
const list = "<ul><li><a href=\"" + contribURL + "\">Submit documentation directly through GitHub's online editor</a></li><li><a href=\"https://github.com/haskellfoundation/error-message-index/blob/main/CONTRIBUTING.md\">Add documentation or examples on your own computer</a> and send a pull request</li></ul>";
21+
const thirdPara = "<p>All contributions are reviewed. We welcome contributions from new Haskellers and non-expert users of English - we'll work together to create high-quality documentation.";
22+
23+
document.getElementById("documentation-pointer").innerHTML = firstPara + secondPara + list + thirdPara;
1224
}
1325
</script>

0 commit comments

Comments
 (0)