Skip to content

Commit 0107676

Browse files
authored
feat: support add document to multiple context paths (#412), closes #407
1 parent 7b527b1 commit 0107676

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

docusaurus-search-local/src/server/utils/postBuildFactory.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,14 @@ export function postBuildFactory(
4848
for (const doc of documents) {
4949
if (doc.u.startsWith(baseUrl)) {
5050
const uri = doc.u.substring(baseUrl.length);
51-
let matchedPath: string | undefined;
51+
let matchedPathes: string[] = [];
5252
for (const _path of searchContextByPaths) {
5353
const path = typeof _path === "string" ? _path : _path.path;
5454
if (uri === path || uri.startsWith(`${path}/`)) {
55-
matchedPath = path;
56-
break;
55+
matchedPathes.push(path);
5756
}
5857
}
59-
if (matchedPath) {
58+
for (const matchedPath of matchedPathes) {
6059
let dirAllDocs = docsByDirMap.get(matchedPath);
6160
if (!dirAllDocs) {
6261
dirAllDocs = [];
@@ -67,9 +66,9 @@ export function postBuildFactory(
6766
dirAllDocs[docIndex] = dirDocs = [];
6867
}
6968
dirDocs.push(doc);
70-
if (!useAllContextsWithNoSearchContext) {
71-
continue;
72-
}
69+
}
70+
if (matchedPathes.length > 0 && !useAllContextsWithNoSearchContext) {
71+
continue;
7372
}
7473
}
7574
rootAllDocs[docIndex].push(doc);

0 commit comments

Comments
 (0)