mirror of
https://github.com/facebook/docusaurus.git
synced 2025-07-21 02:27:49 +02:00
feat(v2): contextual search, dynamic Algolia facetFilters (#3550)
* POC of contextual search dynamic filters * fix useSearchTags bugs * contextual search should use preferred version (persisted in storage) * Contextual search: make system decoupled from algolia + wire proper meta tags and facet filters * rework doc tag + minor refactorings * update snapshots * polish contextual search * add Algolia validateThemeConfig tests
This commit is contained in:
parent
d23940c9c3
commit
21264f5ed0
21 changed files with 468 additions and 138 deletions
packages/docusaurus-plugin-content-docs/src/theme/hooks
|
@ -19,6 +19,7 @@ import {
|
|||
getActiveDocContext,
|
||||
getDocVersionSuggestions,
|
||||
GetActivePluginOptions,
|
||||
ActivePlugin,
|
||||
} from '../../client/docsClientUtils';
|
||||
|
||||
export const useAllDocsData = (): Record<string, GlobalPluginData> =>
|
||||
|
@ -33,6 +34,23 @@ export const useActivePlugin = (options: GetActivePluginOptions = {}) => {
|
|||
return getActivePlugin(data, pathname, options);
|
||||
};
|
||||
|
||||
export const useActivePluginAndVersion = (
|
||||
options: GetActivePluginOptions = {},
|
||||
):
|
||||
| undefined
|
||||
| {activePlugin: ActivePlugin; activeVersion: GlobalVersion | undefined} => {
|
||||
const activePlugin = useActivePlugin(options);
|
||||
const {pathname} = useLocation();
|
||||
if (activePlugin) {
|
||||
const activeVersion = getActiveVersion(activePlugin.pluginData, pathname);
|
||||
return {
|
||||
activePlugin,
|
||||
activeVersion,
|
||||
};
|
||||
}
|
||||
return undefined;
|
||||
};
|
||||
|
||||
// versions are returned ordered (most recent first)
|
||||
export const useVersions = (pluginId: string | undefined): GlobalVersion[] => {
|
||||
const data = useDocsData(pluginId);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue