Skip to content

Commit 1523376

Browse files
committed
feat: scope local search results per project
1 parent 64adb4c commit 1523376

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

docs/.vitepress/config.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,27 @@ export default defineConfig({
198198
themeConfig: {
199199
logo: "/logo.svg",
200200
outline: [2, 5], // show h2-h5
201-
search: { provider: "local" },
201+
search: {
202+
provider: "local",
203+
options: {
204+
miniSearch: {
205+
searchOptions: {
206+
filter(result) {
207+
const project =
208+
location.pathname.match(/^\/([^/]+)(?:\/|$)/)?.[1];
209+
if (!project) {
210+
return true;
211+
}
212+
213+
return (
214+
result.id === `/${project}/` ||
215+
result.id.startsWith(`/${project}/`)
216+
);
217+
},
218+
},
219+
},
220+
},
221+
},
202222
editLink: {
203223
pattern: ({ filePath }) => {
204224
const repoUrl = "https://github.com/BlueLua";

0 commit comments

Comments
 (0)