Skip to content

Commit

Permalink
Make the 404 page nicer
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanreese committed Sep 17, 2024
1 parent 5d7ac9a commit d42c78f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
1 change: 0 additions & 1 deletion build/build.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,6 @@ for pageName, page of pages
aside = "<aside>\n"

if page.data.contributors?
console.log page.data.contributors
lis = page.data.contributors.split(",").map((c)-> li c.trim()).join ""
aside += indent + " <section><h1>Contributors</h1><ul>#{lis}</ul></section>\n"

Expand Down
15 changes: 10 additions & 5 deletions pages/404.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ title: 404
</div>

<style>
title { display: none }
article { text-align: center; }
@media (min-width: 801px) {
title {
display: none
}
article {
display: grid;
place-content: center;
Expand All @@ -26,6 +25,12 @@ title: 404
</style>

<script>
let name = window.location.pathname.slice(1);
["edit", "new"].forEach((id) => document.getElementById(id).href = `https://github.com/futureofcoding/wiki/new/main/pages?filename=${name}.md&value=---%0Atitle:%20${encodeURI(name)}%0Acontributors:%20Your%20Name%0A---`)
// Grab the trailing part of the URL
let filename = window.location.pathname.slice(1);
// Turn `kebab-case` or `camel_case` or `whatever+this+is` into `Nice Title Case`
let name = filename.split(/[-_+]/g).map(w => w[0].toUpperCase() + w.slice(1)).join(" ");
// Update the `Edit This Page` and `Create It On GitHub` links to pre-populate a new page with the correct filename and title
["edit", "new"].forEach((id) => document.getElementById(id).href = `https://github.com/futureofcoding/wiki/new/main/pages?filename=${filename}.md&value=---%0Atitle:%20${encodeURI(name)}%0Acontributors:%20Your%20Name%0A---`);
// Give the `Edit This Page` button a nicer label
document.querySelector("#edit span").textContent = "Create Page"
</script>

0 comments on commit d42c78f

Please sign in to comment.