mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-13 17:17:28 +02:00
fix(content-docs): make getActivePlugin match plugin paths more exactly (#6435)
* fix(content-docs): make getActivePlugin match plugin IDs more exactly * refactor...
This commit is contained in:
parent
cbcbdaa9d3
commit
64909e7f14
2 changed files with 44 additions and 10 deletions
|
@ -27,14 +27,17 @@ export function getActivePlugin(
|
|||
pathname: string,
|
||||
options: GetActivePluginOptions = {},
|
||||
): ActivePlugin | undefined {
|
||||
const activeEntry = Object.entries(allPluginDatas).find(
|
||||
([_id, pluginData]) =>
|
||||
!!matchPath(pathname, {
|
||||
path: pluginData.path,
|
||||
exact: false,
|
||||
strict: false,
|
||||
}),
|
||||
);
|
||||
const activeEntry = Object.entries(allPluginDatas)
|
||||
// A quick route sorting: '/android/foo' should match '/android' instead of '/'
|
||||
.sort((a, b) => b[1].path.localeCompare(a[1].path))
|
||||
.find(
|
||||
([, pluginData]) =>
|
||||
!!matchPath(pathname, {
|
||||
path: pluginData.path,
|
||||
exact: false,
|
||||
strict: false,
|
||||
}),
|
||||
);
|
||||
|
||||
const activePlugin: ActivePlugin | undefined = activeEntry
|
||||
? {pluginId: activeEntry[0], pluginData: activeEntry[1]}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue