Skip to content

Commit

Permalink
support add document to multiple indexes
Browse files Browse the repository at this point in the history
  • Loading branch information
marsqing committed Jun 4, 2024
1 parent 7b527b1 commit a123de7
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions docusaurus-search-local/src/server/utils/postBuildFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,14 @@ export function postBuildFactory(
for (const doc of documents) {
if (doc.u.startsWith(baseUrl)) {
const uri = doc.u.substring(baseUrl.length);
let matchedPath: string | undefined;
let matchedPathes: string[] = [];
for (const _path of searchContextByPaths) {
const path = typeof _path === "string" ? _path : _path.path;
if (uri === path || uri.startsWith(`${path}/`)) {
matchedPath = path;
break;
matchedPathes.push(path);
}
}
if (matchedPath) {
for (const matchedPath of matchedPathes) {
let dirAllDocs = docsByDirMap.get(matchedPath);
if (!dirAllDocs) {
dirAllDocs = [];
Expand All @@ -67,9 +66,9 @@ export function postBuildFactory(
dirAllDocs[docIndex] = dirDocs = [];
}
dirDocs.push(doc);
if (!useAllContextsWithNoSearchContext) {
continue;
}
}
if (matchedPathes.length > 0 && !useAllContextsWithNoSearchContext) {
continue;
}
}
rootAllDocs[docIndex].push(doc);
Expand Down

0 comments on commit a123de7

Please sign in to comment.