Skip to content

feat: improve 404 page#180

Merged
dcrawbuck merged 2 commits intomainfrom
dcrawbuck/improve-404-page
Apr 29, 2026
Merged

feat: improve 404 page#180
dcrawbuck merged 2 commits intomainfrom
dcrawbuck/improve-404-page

Conversation

@dcrawbuck
Copy link
Copy Markdown
Collaborator

@dcrawbuck dcrawbuck commented Apr 29, 2026

Summary

Improve the docs 404 page so readers can recover with parsed search suggestions, a prefilled search dialog, and clearer links to SDK, Dashboard, and Support docs. Remove the unused Slack 404 reporting endpoint and generated route entries. The related docs preview now follows router location changes so repeated 404 navigation shows suggestions for the current URL.

Checks

  • bunx oxfmt --check src/components/not-found.tsx
  • bun test
  • bun run build:cf

Note

Medium Risk
Adds new client-side search fetching and cross-component event handling on the 404 path, which could impact UX/perf or break if routing/search APIs change. Removal of /api/404-report is low-risk unless external tooling still calls it.

Overview
Upgrades the docs NotFound experience to help users recover: it derives a search query from the missing URL, fetches top related-doc suggestions (static index in prod / /api/search in dev), and adds clearer navigation CTAs plus quick links to key sections.

Introduces a small client-side event bridge (PREFILL_DOCS_SEARCH_EVENT) so the 404 page can open the global search dialog with the query prefilled, and updates CustomSearchDialog to listen for that event and open itself; also switches scheduleIdle’s fallback timers to globalThis.

Removes the unused /api/404-report Slack webhook endpoint and its generated TanStack Router entries (routeTree.gen.ts).

Reviewed by Cursor Bugbot for commit 0095abf. Bugbot is set up for automated code reviews on this repo. Configure here.

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented Apr 29, 2026

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
superwall-docs-staging 9354e07 Commit Preview URL

Branch Preview URL
Apr 29 2026, 01:18 AM

@dcrawbuck dcrawbuck changed the title Improve docs 404 page feat: improve 404 page Apr 29, 2026
@dcrawbuck dcrawbuck marked this pull request as ready for review April 29, 2026 01:28
@dcrawbuck dcrawbuck merged commit 0274449 into main Apr 29, 2026
3 checks passed
@dcrawbuck dcrawbuck deleted the dcrawbuck/improve-404-page branch April 29, 2026 01:28
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9354e07cdb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".


function parseSearchQueryFromUrl(pathname: string, hash: string): string {
const rawPath = `${pathname}${hash ? `/${hash.replace(/^#/, "")}` : ""}`;
const withoutDocsPrefix = rawPath.replace(/^\/?docs\/?/, "");
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Strip docs prefix only when it is a full path segment

The prefix removal in parseSearchQueryFromUrl uses rawPath.replace(/^\/?docs\/?/, ""), which also matches URLs whose first segment merely starts with docs (for example, /docs-as-code or /docsify/...). In those cases the generated query is truncated (-as-code, ify ...), so the 404 page suggests unrelated docs and pre-fills the search dialog with the wrong text. This should only remove /docs when it is an entire segment (e.g., followed by / or end-of-string).

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant