web: don't render the search bar when orama-db isn't enabled#893
web: don't render the search bar when orama-db isn't enabled#893devthedevil wants to merge 2 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
PR SummaryMedium Risk Overview The Note: The diff also replaces Reviewed by Cursor Bugbot for commit 45bb9a4. Bugbot is set up for automated code reviews on this repo. Configure here. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 45bb9a4. Configure here.
| */ | ||
| export default ({ metadata }) => { | ||
| const [themePreference, setThemePreference] = useTheme(); | ||
| const [themePreference, setThemePreference] = useState(); |
There was a problem hiding this comment.
Theme hook replaced incorrectly
High Severity
useTheme() was swapped for bare useState() while the useTheme import remains. useState is not imported from React, so the navbar can throw at runtime. Even with an import, theme would not load from localStorage, would not apply data-theme on the document, and ThemeToggle would get an undefined currentTheme.
Reviewed by Cursor Bugbot for commit 45bb9a4. Configure here.
avivkeller
left a comment
There was a problem hiding this comment.
You can't read the full config from within a generator. You can only read the config for that generator


Summary
The
webgenerator'sNavBarunconditionally renders<SearchBox>, even when the site was generated without theorama-dbgenerator. In that case there's no/orama-db.jsonindex foruseOramato fetch, so the search bar appears in the UI but is entirely non-functional (typing into it never returns results).Change
src/generators/web/utils/config.mjs: the#theme/configvirtual module now also exportshasSearch, computed from the full run configuration'stargetlist (getConfig().target.includes('orama-db')).src/generators/web/ui/components/NavBar.jsx: importshasSearchfrom#theme/configand only renders<SearchBox>when it'strue.This mirrors how other optional, generator-dependent UI is already gated, and keeps the change scoped to the two files that need it.
Testing
src/generators/web/utils/__tests__/config.test.mjs: it only exercisesbuildVersionEntries,buildPageList, andbuildLanguageDisplayNameMap, none of which are touched by this change, so the existing suite continues to pass as-is.getConfig()(no argument) returns the full merged configuration object (includingtarget), whilegetConfig('web')returns only the per-generator config thatcreateConfigSourcewas already destructuring - sohasSearchreads from the right place.Closes #891