From 760f7cb26d98825f0f6cb58c4140ebd97eb676c2 Mon Sep 17 00:00:00 2001 From: Zheyuan Wu <60459821+Trance-0@users.noreply.github.com> Date: Fri, 7 Nov 2025 00:47:01 -0600 Subject: [PATCH] fixed docsearch!!! --- components/docsearch.tsx | 20 ++++++++++++++++++-- next-env.d.ts | 1 + package.json | 22 +++++++++++----------- tsconfig.json | 5 +++-- 4 files changed, 33 insertions(+), 15 deletions(-) diff --git a/components/docsearch.tsx b/components/docsearch.tsx index 37c6d4d..1627965 100644 --- a/components/docsearch.tsx +++ b/components/docsearch.tsx @@ -7,8 +7,8 @@ import {useTheme} from 'next-themes'; import '@docsearch/css'; function AlgoliaSearch () { - const {theme} = useTheme(); - const darkMode = theme === 'dark'; + const {theme, systemTheme} = useTheme(); + const darkMode = theme === 'dark' || (theme === 'system' && systemTheme === 'dark'); console.log("darkMode", darkMode); return ( + // DocSearch lets you sanitize results before render. Filter out hits that don’t have a URL and give lvl0 a safe fallback. + items + .filter((i) => typeof i.url === 'string' && i.url) // drop records with null/empty url + .map((i) => ({ + ...i, + hierarchy: { + ...i.hierarchy, + // ensure strings for all places DocSearch prints text + lvl0: i.hierarchy?.lvl0 ?? i.hierarchy?.lvl1 ?? 'Documentation', + }, + })) + } + // END OF CODE GENERATED BY AI /> ); } diff --git a/next-env.d.ts b/next-env.d.ts index 1b3be08..c4b7818 100644 --- a/next-env.d.ts +++ b/next-env.d.ts @@ -1,5 +1,6 @@ /// /// +import "./.next/dev/types/routes.d.ts"; // NOTE: This file should not be edited // see https://nextjs.org/docs/app/api-reference/config/typescript for more information. diff --git a/package.json b/package.json index e21f2f8..fa1cfcf 100644 --- a/package.json +++ b/package.json @@ -8,23 +8,23 @@ "start": "next start" }, "dependencies": { - "@docsearch/react": "^4.0.0-beta.2", + "@docsearch/react": "^4.3.1", "@napi-rs/simple-git": "^0.1.22", - "@next/bundle-analyzer": "^15.3.5", + "@next/bundle-analyzer": "^16.0.1", "@vercel/analytics": "^1.5.0", "@vercel/speed-insights": "^1.2.0", - "cross-env": "^7.0.3", - "katex": "^0.16.22", - "next": "^15.5.2", + "cross-env": "^10.1.0", + "katex": "^0.16.25", + "next": "^16.0.1", "next-sitemap": "^4.2.3", - "nextra": "^4.2.17", - "nextra-theme-docs": "^4.2.17", + "nextra": "^4.6.0", + "nextra-theme-docs": "^4.6.0", "pagefind": "^1.4.0", - "react": "^19.1.0", - "react-dom": "^19.1.0" + "react": "^19.2.0", + "react-dom": "^19.2.0" }, "devDependencies": { - "@types/node": "24.0.10", - "@types/react": "19.1.8" + "@types/node": "24.10.0", + "@types/react": "19.2.2" } } diff --git a/tsconfig.json b/tsconfig.json index 1fda10e..3f22d98 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -16,7 +16,7 @@ "moduleResolution": "bundler", "resolveJsonModule": true, "isolatedModules": true, - "jsx": "preserve", + "jsx": "react-jsx", "plugins": [ { "name": "next" @@ -28,7 +28,8 @@ "**/*.ts", "**/*.tsx", "next-env.d.ts", - ".next/types/**/*.ts" + ".next/types/**/*.ts", + ".next/dev/types/**/*.ts" ], "exclude": [ "node_modules"