Skip to content

Commit a50e9a3

Browse files
committed
Add a witty(ish) 404 page for bad dates on the new-extensions route.
1 parent 93aea45 commit a50e9a3

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/pages/404.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,23 @@ import { initialiseDisplayModeFromLocalStorage } from "../components/util/dark-m
88
const NotFoundPage = ({ data, location }) => {
99
const siteTitle = data.site.siteMetadata.title
1010

11+
const isLookingForNewExtensions = location.pathname && location.pathname.includes("/new-extensions/")
12+
const isPast = location.pathname && location.pathname.includes("/new-extensions/201")
13+
const isFuture = location.pathname && location.pathname.includes("/new-extensions/202")
14+
15+
let message
16+
if (isLookingForNewExtensions) {
17+
const date = location.pathname.replaceAll("/new-extensions/", "").split("/").reverse().join(" ")
18+
const explanation = isPast ? `No Quarkus extensions were released in ${date}.` : isFuture ? `The Quarkus extensions for ${date} haven't been created yet.` : `There are no Quarkus extensions for ${date}.`
19+
message = "Quarkus contributors can do a lot of nifty things, but time travel isn't one of them. " + explanation
20+
} else {
21+
message = "You just hit a route that doesn't exist... the sadness."
22+
}
23+
1124
return (
1225
<Layout location={location} title={siteTitle}>
1326
<h1>404: Not Found</h1>
14-
<p>You just hit a route that doesn&#39;t exist... the sadness.</p>
27+
<p>{message}</p>
1528
</Layout>
1629
)
1730
}

0 commit comments

Comments
 (0)