Skip to content

Proposal: dynamic search namespace #1303

Closed
@palkan

Description

@palkan

Feature request

What problem does this feature solve?

Make it possible to dynamically change search namespace to isolate different parts of the documentation.
For example, we can isolate different locales from each other while using aliases. Right now, search index is built for all pages, and hence some queries return results for multiple locales at once (try searching for index.html at https://docsify.js.org/).

What does the proposed API look like?

I'm currently using a patched version of the search plugin which updates CONFIG.namespace in afterEach callback by using the value from vm.config.search.namespace: https://github.com/test-prof/docs/blob/cb7826d37b37a338df64830fa85f6132f82992a6/docs/assets/docsify-search.js#L325

Thus, in order to change the namespace you need to update vm.config.search.namespace in your plugin.

That works fine for me but it's not an ideal solution.

Probably, exposing an API to switch the namespace would be better, e.g.: vm.config.search.switchNamespace(...) or even vm.plugins.search.switchNamespace(...).

How should this be implemented in your opinion?

Long term: provide and API to access plugin instances, and thus making it possible to communicate with plugins from other plugins.

Short term: update namespace from the current vm.config settings in the init function:

export function init(config, vm) {

Are you willing to work on this yourself?

Sure.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions