Drop dead code: kbar search index, MDX video mapping, unused components and dependencies - #1997
Open
marcleblanc2 wants to merge 11 commits into
Open
marcleblanc2 wants to merge 11 commits into
marcleblanc2 wants to merge 11 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
Contributor
|
marcleblanc2
force-pushed
the
marc/chore/drop-kbar-search-index
branch
from
September 18, 2026 04:27
759b5e0 to
e5be987
Compare
Production serves under /docs. next/link adds the prefix, <img> and next/image do not, so /sourcegraph-mark.svg in the mobile nav and the LinkCards/ProductCards icons, plus a couple of root-relative markdown images, 404 on sourcegraph.com.
Amp-Thread-ID: https://ampcode.com/threads/T-01a0ae6a-1645-702a-a5ed-92f8b9bce33b Co-authored-by: Amp <amp@ampcode.com>
Previews and local dev served at / while production served at /docs, so a root-relative <img src> only 404d after deploy. Use basePath /docs everywhere; the / -> /docs redirect from #1955 now applies to every deployment. Update the tooling that assumed previews had no basePath. Amp-Thread-ID: https://ampcode.com/threads/T-01a0ae6a-1645-702a-a5ed-92f8b9bce33b Co-authored-by: Amp <amp@ampcode.com>
basePath is declared once, in docs.config.js. next.config.js reads it for
routing; everything that builds a URL Next does not prefix (img src, a href,
fetch, metadata, proxy redirects) goes through withBasePath or reads the
constant, instead of nine copies of process.env.NEXT_PUBLIC_DOCS_BASE_PATH
or a hardcoded '/docs'.
proxy.ts: request.nextUrl.pathname already excludes the basePath, so the
path.replace('/docs', '') was a no-op that would have mangled any real
path containing '/docs'. Removed.
Amp-Thread-ID: https://ampcode.com/threads/T-01a0ae6a-1645-702a-a5ed-92f8b9bce33b
Co-authored-by: Amp <amp@ampcode.com>
/v/<latest>/x and /@<latest>/x redirected to https://sourcegraph.com/docs/x even from a preview or local dev, so a reviewer testing those paths on a preview silently landed on production. The current deployment serves the latest version, so redirect to its own origin + DOCS_BASE_PATH instead. Also merges the identical /v/ and /@ branches. Amp-Thread-ID: https://ampcode.com/threads/T-01a0ae6a-1645-702a-a5ed-92f8b9bce33b Co-authored-by: Amp <amp@ampcode.com>
The basePath has moved three times. Next time, change DOCS_BASE_PATH (and DOCS_PROD_ORIGIN if the host moves) in docs.config.js and nothing else: - versions.ts, api/versions, VersionSelector, sitemap, robots, Search and the layout canonical/metadataBase read DOCS_BASE_PATH / DOCS_PROD_URL instead of spelling out /docs or https://sourcegraph.com/docs - check-redirects, check-links (self-link regex) and verify-links-live import docs.config.js - preview-links.yml checks out the PR's docs.config.js to build page URLs - search.ts searchDocumentsPath is root-relative like every public/ path; it is only a flag for writing public/search.json .amp/services.yaml is YAML and keeps its literal path, with a note. Amp-Thread-ID: https://ampcode.com/threads/T-01a0ae6a-1645-702a-a5ed-92f8b9bce33b Co-authored-by: Amp <amp@ampcode.com>
kbar was removed in #110; the contentlayer onSuccess hook kept writing a 725 KB public/search.json that nothing fetched. src/utils/contentlayer.ts only existed to build that index. MDX compiles an explicit <video> to a literal element, so components.video never ran; the rounded-xl class it set was never applied. Co-authored-by: Amp <amp@ampcode.com> Amp-Thread-ID: https://ampcode.com/threads/T-01a0ae6a-1645-702a-a5ed-92f8b9bce33b
…exports knip flagged these and rg confirms nothing imports them: - docsearch/icons/index.ts barrel, and the AlgoliaLogo, NoResultsIcon, ControlKeyIcon, GoToExternalIcon icons only it re-exported. The two commented-out usages in Footer.tsx and NoResultsScreen.tsx go with them, along with the searchByText translation that only fed AlgoliaLogo - docsearch/types/useDocSearchKeyboardEvents.ts, a drifted copy of the sibling hook DocSearch.tsx actually imports - src/images/logos/aws/index.ts, generator output from before dev/generate-mermaid-icons.mjs switched to icons.generated.ts - latestVersion in src/data/versions.ts, exported since #48 with no reader Amp-Thread-ID: https://ampcode.com/threads/T-01a0ae6a-1645-702a-a5ed-92f8b9bce33b Co-authored-by: Amp <amp@ampcode.com>
- @iconify-json/logos and @iconify/types: nothing in src/, dev/, or any config references them; Mermaid icon packs come from src/images/logos/*/icons.generated.ts - mdx: not MDX at all, a 2013 "generic documentation extractor", most likely a typo-install of @mdx-js/mdx. Nothing imports it Amp-Thread-ID: https://ampcode.com/threads/T-01a0ae6a-1645-702a-a5ed-92f8b9bce33b Co-authored-by: Amp <amp@ampcode.com>
marcleblanc2
force-pushed
the
marc/chore/drop-kbar-search-index
branch
from
September 18, 2026 05:05
a781d29 to
e7aa180
Compare
marcleblanc2
changed the base branch from
main
to
marc/fix/mark-svg-base-path
September 18, 2026 05:05
None of these packages are imported by src/, dev/, or any config file: @docsearch/react (only its CSS is vendored), @mdx-js/mdx, date-fns, fast-glob, feed, prism-react-renderer, react-highlight-words and its @types, react-syntax-highlighter, rehype-toc, simple-functional-loader, dotenv. public/changelog.rss and public/technical-changelog.rss are no longer generated here: the feed is served from sourcegraph.com (see src/data/constants.ts) and src/proxy.ts redirects to it. Amp-Thread-ID: https://ampcode.com/threads/T-01a0ad56-bd79-73ce-bc8e-a5405d0c11f2 Co-authored-by: Amp <amp@ampcode.com>
PreCode.tsx was empty; ResourceEstimator.tsx was an older copy of resource-estimator/ResourceEstimator.tsx, which MdxComponents imports; DemoLayout, TopBanner, Globe and BugIcon have no importers. allCoreContent filtered on a `draft` frontmatter field that contentlayer.config.ts does not declare and no page sets, so the production and development branches did the same thing. Amp-Thread-ID: https://ampcode.com/threads/T-01a0ad56-bd79-73ce-bc8e-a5405d0c11f2 Co-authored-by: Amp <amp@ampcode.com>
enriquegh
approved these changes
Sep 18, 2026
enriquegh
left a comment
Contributor
There was a problem hiding this comment.
very nice! so much dead code 💀
So much came from us moving from kbar to algolia then we had to bring in the docsearch component instead of importing it (I think we couldn't customize otherwise) and brought too much with it.
marcleblanc2
force-pushed
the
marc/fix/mark-svg-base-path
branch
from
September 18, 2026 21:23
6b9f3cb to
dcdddd0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
src/data/search.tsand the contentlayeronSuccesshook stayed behind, writing a 725 KBpublic/search.jsonon every build that nothing fetchessrc/utils/contentlayer.tsonly existed to build that indexvideoentry inMdxComponents.tsxnever runs: MDX compiles an explicit<video>to a literal element, socomponents.videois never consulted (therounded-xlclass it set has never been applied)docsearch/icons/index.tsbarrel and theAlgoliaLogo,NoResultsIcon,ControlKeyIcon,GoToExternalIconicons only it re-exported (plus two commented-out usages and thesearchByTexttranslation that only fedAlgoliaLogo)docsearch/types/useDocSearchKeyboardEvents.ts, a drifted copy of the sibling hookDocSearch.tsxactually importssrc/images/logos/aws/index.ts, generator output from beforedev/generate-mermaid-icons.mjsswitched toicons.generated.tslatestVersioninsrc/data/versions.ts, exported since 📦 NEW: Add versioning #48 with no reader@iconify-json/logos,@iconify/types, andmdx(not MDX: a 2013 "generic documentation extractor", likely a typo-install of@mdx-js/mdx)package.json, the lockfile,.gitignore, andsrc/utils/contentlayer.ts):src/components/PreCode.tsx(empty; the realPreCodelives inPreCodeBlock.tsx),src/components/ResourceEstimator.tsx(older duplicate ofresource-estimator/ResourceEstimator.tsx),src/components/DemoLayout.tsx(template leftover),src/components/TopBanner.tsx,src/components/icons/Globe.tsx,src/components/icons/BugIcon.tsxsrc/,dev/, or any config:@docsearch/react(only its CSS is vendored undersrc/components/search/docsearch/),@mdx-js/mdx(contentlayer2 pulls the same 3.1.1 transitively),date-fns,fast-glob,feed,prism-react-renderer,react-highlight-words+@types/react-highlight-words,react-syntax-highlighter,rehype-toc,simple-functional-loader,dotenv. Kept on purpose:shiki(peer ofrehype-pretty-code) andsharp.gitignoreentries forpublic/changelog.rssandpublic/technical-changelog.rss: nothing generates them; the feed comes from sourcegraph.com andsrc/proxy.tsredirects the old pathsChange
Five commits, one per group above. 15 files deleted, 15 dependencies removed, +1 −1585 (880 of that lockfile).
Based on #1977 so GitHub shows only this PR's diff; retarget to
mainonce #1977 lands.Verification
pnpm install --frozen-lockfile,npx tsc --noEmitclean,pnpm run lintat the 8-warning baseline,pnpm run buildpasses and no longer producespublic/search.jsonrg -i 'kbar|search\.json'finds nothing;rgfinds no imports of any deleted file, export, or dependency<video>markup on/docs/code-monitoringis byte-identical before and after (it never had the class)search.json: the new Algolia indexer (Revamp docs search: product-keyed Algolia index, ranking fixes, denser modal #2009) reads.contentlayer/generated/Post, the old DocSearch crawler scraped HTML, and Cloudflare analytics forsourcegraph.comshow ~150 sampled requests to/docs/search.jsonin the last 30 days, all with an empty referer, random geos and browser UAs, and no daily cadence: scanner noise, not a consumer