Skip to content

Commit

Permalink
Update to proper 404
Browse files Browse the repository at this point in the history
  • Loading branch information
josh-collinsworth committed Nov 22, 2024
1 parent 3bae1a0 commit 642c3db
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 22 deletions.
12 changes: 3 additions & 9 deletions 404/index.page.tsx → 404.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const layout = "raw.tsx";
export const url = "/404";
import { sidebar } from "../runtime/_data.ts";
export const url = "/404.html";
import { sidebar } from "./runtime/_data.ts";

const styles = /*css*/ `
#content nav {
Expand Down Expand Up @@ -42,13 +42,7 @@ export default function Page(props: Lume.Data, helpers: Lume.Helpers) {
<h1 class="text-2xl font-semibold sm:text-3xl md:text-4xl">
Sorry, couldn’t find that page.
</h1>
<p class="text-sm mt-3">
Failed to match route{" "}
<code class="p-1 rounded bg-foreground-tertiary" id="tried-path">
404
</code>
</p>
<p class="md:text-lg mt-6">
<p class="md:text-lg mt-4">
Maybe one of these links has what you're looking for?
</p>
</div>
Expand Down
6 changes: 3 additions & 3 deletions _config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,9 @@ site.process([".html"], (pages) => {
const document = page.document!;
if (!document.querySelector(".ddoc")) {
document.body.classList.add("apply-prism");
document.querySelectorAll("body.apply-prism pre code").forEach((
element,
) => Prism.highlightElement(element));
document
.querySelectorAll("body.apply-prism pre code")
.forEach((element) => Prism.highlightElement(element));
}
}
});
Expand Down
9 changes: 8 additions & 1 deletion deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 0 additions & 9 deletions middleware/redirects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,6 @@ export default async function redirectsMiddleware(
res = await next(req);
}

if (res.status === 404) {
res = new Response(null, {
headers: {
location: "/404" + "?path=" + encodeURIComponent(url.pathname)
},
status: 303,
});
}

return res;
} catch (e) {
res = new Response("Internal Server Error", {
Expand Down

0 comments on commit 642c3db

Please sign in to comment.