Skip to content

Pass transformItems to SearchBar #8461

@mturoci

Description

@mturoci

Have you read the Contributing Guidelines on issues?

Prerequisites

Description

One of Algolia config options should be transformItems function which can filter/reorder the incoming search results prior to displaying to the user.

However, it seems like this function is not being picked up when defined in Docusaurus config at all.

Reproducible demo

https://stackblitz.com/edit/github-mfcf4x?file=docusaurus.config.js

Steps to reproduce

  1. Add algolia config to docusaurus.config.js:
themeConfig: {
  algolia: {
    appId: 'X1Z85QJPUV',
    apiKey: 'bf7211c161e8205da2f933a02534105a',
    indexName: 'docusaurus-2',
    contextualSearch: true,
    transformItems: (items) => {
      console.log(items); // This should log search hits, but does not.
      return items;
    }
  },
}
  1. Try to search for something that returns results.
  2. Observe the console if the search hits are logged.

Expected behavior

Search hits should be logged to the console.

Actual behavior

Search hits are not logged to the console.

Your environment

Self-service

  • I'd be willing to fix this bug myself.

Metadata

Metadata

Assignees

No one assigned

    Labels

    domain: searchRelated to the search feature, usually AlgoliafeatureThis is not a bug or issue with Docusausus, per se. It is a feature request for the future.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions