I'm attempting implementation of TS in Docusaurus....
# community-help
b
I'm attempting implementation of TS in Docusaurus. I've set up the scraper and implemented the config, .env, CSS and scraper.json. When I try to run the site I get: [ERROR] TypeError: Cannot read properties of undefined (reading 'searchPagePath') I've tried adding SearchPagePath to the config and set it both to false as well as a path. Regardless of which I get above error. The good folks over at the Docusaurus discord suggested that I reach out here as this seems like a bug in the Typesense plugin? Running latest both docusaurus and TS. This is the documenation I've followed.
j
Could you share your
docusaurus.config.js
?
b
j
Ah, this part should be moved up one level and not nested:
Copy code
{
      // ... Other configs
      themes: ['docusaurus-theme-search-typesense'],
      themeConfig: {
        typesense: {
          searchPagePath: false,
          typesenseCollectionName: 'my-website', // Replace with your own doc site's name. Should match the collection name in the scraper settings.
          typesenseServerConfig: {
            nodes: [
              {
                host: '192.168.1.34',
                port: 8108,
                protocol: 'http',
              }
            ],
            apiKey: 'Co8BCCK81Hd45tbBIC0UKNGBgtgDQ25aSDhgKfRK5TX0zAVs',
          },
          // Optional
          contextualSearch: true,
        },
      }
      // ... Other configs
}
πŸ™ 1
Notice how there’s already a
themeConfig
key in the top level
πŸ™Œ 1
b
Aha, of course! Much appreciate the swift response :-)
πŸ‘ 1
j
typesense
should just be inside that key
Mind posting this update in Docusaurus Discord as well for future searchers?
b
I will indeed πŸ™‚
πŸ™ 1
Can't quite get this to work. I've put
typesense
inside the themeConfig block, but I guess I somehow have to import this the same way that the docusaurus preset-classic is imported
@type {import('@docusaurus/preset-classic').ThemeConfig}
?
Copy code
themeConfig:
    /** @type {import('@docusaurus/preset-classic').ThemeConfig} */
    ({
      navbar: {
        title: 'My Site',
        logo: {
          alt: 'My Site Logo',
          src: 'img/logo.svg',
        },
        items: [
          {
            type: 'doc',
            docId: 'intro',
            position: 'left',
            label: 'Tutorial',
          },
          {to: '/blog', label: 'Blog', position: 'left'},
          {
            href: '<https://github.com/facebook/docusaurus>',
            label: 'GitHub',
            position: 'right',
          },
        ],
      },
        typesense: {
          searchPagePath: false,
          typesenseCollectionName: 'my-website', // Replace with your own doc site's name. Should match the collection name in the scraper settings.
          typesenseServerConfig: {
            nodes: [
              {
                host: '192.168.1.34',
                port: 8108,
                protocol: 'http',
              }
            ],
            apiKey: 'Co8BCCK81Hd45tbBIC0UKNGBgtgDQ25aSDhgKfRK5TX0zAVs',
          },
          // Optional
          contextualSearch: true,
        },
      footer: {
        style: 'dark',
        links: [
j
Hmm, could you try removing
/** @type {import('@docusaurus/preset-classic').ThemeConfig} */
to see if that helps?
b
Ok lets see
Nope that did nothing 😞
Just to clarify, I'm not receiving the error anymore and the site comes up. But the searchbar is nowhere to be seen
To rule out issues with the config file, could you perhaps share a sample docusaurus config file where the search bar appears on your end?
What do you reckon @Jason Bosco? πŸ™‚
j
I just made public this sandbox repo I've been using to test the plugin. Here's the config from there: https://github.com/typesense/docusaurus-typesense-testground/blob/master/docusaurus.config.js
πŸ‘€ 1
πŸ™Œ 1
b
That was the one indeed! πŸ™‚
πŸ‘ 1