Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with Search Bar Functionality in Nextra Docs Theme #3673

Open
Tracked by #2600
kalinsky-dev opened this issue Nov 8, 2024 · 1 comment
Open
Tracked by #2600

Issue with Search Bar Functionality in Nextra Docs Theme #3673

kalinsky-dev opened this issue Nov 8, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@kalinsky-dev
Copy link

Hello Nextra Team,

My colleagues and I are using the nextra docs-theme to build our documentation site. During development, we encountered an issue: the Search Bar, powered by FlexSearch, does not index content from our custom React components imported in .mdx files. It seems to only index the plain text written directly within the .mdx files.

Upon investigating, we found that the data used by the search bar is sourced from a JSON file located at .next/static/chunks/nextra-data-${locale}.json. This file contains metadata such as the path to the .mdx file, its title, and the data to be indexed. Here's an example of the file's structure:

{
    "/docs/architecture": {
        "title": "Our architecture",
        "data": {
            "how-does-it-work:#How Does It Work?": "some content here",
            "data-collection#Data Collection": "some other content here"
        }
    },
    "/docs/reference-documentation/DataStore": {
        "title": "DataStore",
        "data": {}
    }
}

The DataStore.mdx file imports a React Component and looks like this:

---
title: DataStore
---

import { DataStoreComponent } from '@/components/DataStoreComponent';

<DataStoreComponent data={JSON string} />

When we search for content in the DataStore file, no results are returned, likely because the data object is empty for that file.

Could you offer any guidance on how to resolve this issue so that content from custom React components is indexed properly in the search?

Thank you for your help!

Best regards,
Kalin

@kalinsky-dev kalinsky-dev added the enhancement New feature or request label Nov 8, 2024
@dimaMachina
Copy link
Collaborator

this will be fixed in Nextra 4 with new search engine Pagefind

@dimaMachina dimaMachina mentioned this issue Nov 8, 2024
52 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants