Skip to content

Commit

Permalink
enhance(ux): add catch-all not-found redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
charislam committed Apr 23, 2024
1 parent c1a9b13 commit faa8e35
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
17 changes: 17 additions & 0 deletions apps/docs/app/[...slug]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* A catch-all to redirect all not found pages.
*
* This allows us to generate recommendations based on the path the user is
* looking for, which isn't possible with a regular 404 page (receives no
* params).
*/

import { redirect } from 'next/navigation'
import { sep } from 'node:path'

const CatchAllPage = async ({ params }: { params: { slug: string[] } }) => {
const searchParams = new URLSearchParams({ page: encodeURIComponent(params.slug.join(sep)) })
redirect(`/not-found?${searchParams}`)
}

export default CatchAllPage
9 changes: 0 additions & 9 deletions apps/docs/app/not-found.tsx

This file was deleted.

0 comments on commit faa8e35

Please sign in to comment.