shuding / nextra

Simple, powerful and flexible site generation framework with everything you love from Next.js.
https://nextra.site
MIT License
11.35k stars 1.24k forks source link

Custom search component is being rendered twice #2731

Open nickscamara opened 7 months ago

nickscamara commented 7 months ago

Hi there,

I am having the following weird bug:

In theme.config.tsx, when attempting to render a custom search component below, it appears twice on the page. This duplication can be noticed upon pressing the command shortcut key (CMD K) and is also evident from duplicate network requests.

Any ideas on what could be happening? Thanks!

import React from 'react'
import { DocsThemeConfig } from 'nextra-theme-docs'
import { MendableSearchBar } from '@mendable/search'

const config: DocsThemeConfig = {
  logo: <span>My Project</span>,
  project: {
    link: 'https://github.com/shuding/nextra-docs-template',
  },
  chat: {
    link: 'https://discord.com',
  },
  docsRepositoryBase: 'https://github.com/shuding/nextra-docs-template',
  footer: {
    text: 'Nextra Docs Template',
  },
  search: {component:<div><MendableSearchBar anon_key="" showSimpleSearch /></div>},

}

export default config
dimaMachina commented 7 months ago

please provide reproduction repo

nickscamara commented 7 months ago

@dimaMachina here it is: https://github.com/mendableai/nextra-test

It is just a fork of the template, with the mendable component added. Thank you.

dimaMachina commented 7 months ago

you need to pass className prop to search container element like

component: (props) => <div {...props}><MendableSearchBar anon_key="" showSimpleSearch /></div>