Closed The-Real-Thisas closed 2 years ago
customSearch
should be a React Component, not true/false.
So you need a docsearch.js
file like this: https://github.com/vercel/swr-site/blob/88d1b8affa7f1c344f3aaba229b51867b2cedc8d/components/docsearch.js (modify the API key), and then import it inside your theme:
import Docsearch from './docsearch'
...
customSearch: <Docsearch/>,
The script needs to be included in pages/_document.js
like https://github.com/vercel/swr-site/blob/88d1b8affa7f1c344f3aaba229b51867b2cedc8d/pages/_document.js.
I think we should add an example for Algolia. For now please check https://github.com/vercel/swr-site/tree/88d1b8affa7f1c344f3aaba229b51867b2cedc8d (not latest master) for reference.
I have a bit of an issue with this.
error - ./theme.config.js:1:0
Module not found: Can't resolve './docsearch'
> 1 | import Docsearch from './docsearch'
2 |
3 | export default {
4 | repository: 'https://github.com/The-Real-Thisas/igcse-chem',
I have a _docsearch.js file in pages/_docsearch.js
and I have my theme.config.js
set to
import Docsearch from './docsearch'
export default {
repository: 'https://github.com/The-Real-Thisas/igcse-chem',
docsRepository: 'https://github.com/The-Real-Thisas/igcse-chem',
titleSuffix: ' – IGCSE Chem',
logo: (
<>
<span className="mr-2 font-extrabold hidden md:inline">IGCSE</span>
<span className="text-gray-600 font-normal hidden md:inline">
Chemistry
</span>
</>
),
head: (
<>
<meta name="og:title" content="IGCSE | Chemistry" />
<meta name="og:image" content="https://igcse-chem.vercel.app/demo.png" />
</>
),
search: true,
customSearch: <Docsearch/>,
prevLinks: true,
nextLinks: true,
footer: true,
footerEditOnGitHubLink: true,
footerText: <>MIT {new Date().getFullYear()} © Thisas.</>
}
It appears to be a problem with importing the docsearch file but I don't know why.
Also, thank you so much for the reply. I really appreciate it.
Situation
So I have nexta set up the way I like it but the issue is I want to change the default search to alogia but I can't seem to do that.
Problem
There are two sub problems to this :
There is an option in the theme.config.js that you can toggle to supposedly use a custom search.
When you change
customSearch
to true then the search bar just disappears and is nowhere to be seen. I need this to be an input field that can be mapped to algoila.The second problem is with the javascript script tag I need to have as part of frontend.
Here the first issue is getting the body script to work since adding this to theme.config.js it doesn't work as
}
causes an error to occurs. Further, I have no clue how I'm supposed to link the input field via the 'inputSelector' variable.