update dependencies and fix algolia search.
This commit is contained in:
@@ -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
|
||||
@@ -16,6 +16,22 @@ function AlgoliaSearch () {
|
||||
indexName={process.env.NEXT_SEARCH_ALGOLIA_INDEX_NAME || 'notenextra_trance_0'}
|
||||
apiKey={process.env.NEXT_SEARCH_ALGOLIA_API_KEY || '727b389a61e862e590dfab9ce9df31a2'}
|
||||
theme={darkMode===false ? 'light' : 'dark'}
|
||||
// this is the first time that AI is solving some problem that I have no idea how to solve
|
||||
// BEGIN OF CODE GENERATED BY AI
|
||||
transformItems={(items) =>
|
||||
// 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
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user