@vuepress-plume/plugin-search 1.0.0-rc.161 → 1.0.0-rc.163
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -21,8 +21,7 @@ const defaultLocales = { "/": {
|
|
|
21
21
|
function useLocale(locales) {
|
|
22
22
|
const localesRef = toRef(locales);
|
|
23
23
|
const routeLocale = useRouteLocale();
|
|
24
|
-
|
|
25
|
-
return locale;
|
|
24
|
+
return computed(() => localesRef.value[routeLocale.value] ?? defaultLocales[routeLocale.value] ?? defaultLocales["/"]);
|
|
26
25
|
}
|
|
27
26
|
|
|
28
27
|
//#endregion
|
package/lib/node/index.js
CHANGED
|
@@ -187,15 +187,13 @@ async function prepareSearchIndex({ app, isSearchable, searchOptions }) {
|
|
|
187
187
|
if (app.env.isDebug) logger.info(`\n[${colors.green("@vuepress-plume/plugin-search")}] prepare search time spent: ${(performance.now() - start).toFixed(2)}ms`);
|
|
188
188
|
}
|
|
189
189
|
async function onSearchIndexUpdated(filepath, { app, isSearchable, searchOptions }) {
|
|
190
|
-
|
|
191
|
-
if (pages.some((p) => p.filePathRelative?.endsWith(filepath))) {
|
|
190
|
+
if ((isSearchable ? app.pages.filter(isSearchable) : app.pages).some((p) => p.filePathRelative?.endsWith(filepath))) {
|
|
192
191
|
await indexFile(app.pages.find((p) => p.filePathRelative?.endsWith(filepath)), searchOptions);
|
|
193
192
|
await writeTemp(app);
|
|
194
193
|
}
|
|
195
194
|
}
|
|
196
195
|
async function onSearchIndexRemoved(filepath, { app, isSearchable, searchOptions }) {
|
|
197
|
-
|
|
198
|
-
if (pages.some((p) => p.filePathRelative?.endsWith(filepath))) {
|
|
196
|
+
if ((isSearchable ? app.pages.filter(isSearchable) : app.pages).some((p) => p.filePathRelative?.endsWith(filepath))) {
|
|
199
197
|
const page = app.pages.find((p) => p.filePathRelative?.endsWith(filepath));
|
|
200
198
|
const fileId = page.path;
|
|
201
199
|
const locale = page.pathLocale;
|
|
@@ -209,8 +207,7 @@ async function writeTemp(app) {
|
|
|
209
207
|
const records = [];
|
|
210
208
|
for (const [locale] of indexByLocales) {
|
|
211
209
|
const index = indexByLocales.get(locale);
|
|
212
|
-
const
|
|
213
|
-
const filename = `searchBox-${localeName}.js`;
|
|
210
|
+
const filename = `searchBox-${locale.replace(/^\/|\/$/g, "").replace(/\//g, "_") || "default"}.js`;
|
|
214
211
|
records.push(`${JSON.stringify(locale)}: () => import('@${SEARCH_INDEX_DIR}${filename}')`);
|
|
215
212
|
await app.writeTemp(`${SEARCH_INDEX_DIR}${filename}`, `export default ${JSON.stringify(JSON.stringify(index) ?? {})}`);
|
|
216
213
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vuepress-plume/plugin-search",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.0-rc.
|
|
4
|
+
"version": "1.0.0-rc.163",
|
|
5
5
|
"description": "The Plugin for VuePress 2 - local search",
|
|
6
6
|
"author": "pengzhanbo <volodymyr@foxmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -35,14 +35,14 @@
|
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@vuepress/helper": "2.0.0-rc.112",
|
|
38
|
-
"@vueuse/core": "^13.
|
|
39
|
-
"@vueuse/integrations": "^13.
|
|
38
|
+
"@vueuse/core": "^13.9.0",
|
|
39
|
+
"@vueuse/integrations": "^13.9.0",
|
|
40
40
|
"chokidar": "4.0.3",
|
|
41
41
|
"focus-trap": "^7.6.5",
|
|
42
42
|
"mark.js": "^8.11.1",
|
|
43
43
|
"minisearch": "^7.1.2",
|
|
44
44
|
"p-map": "^7.0.3",
|
|
45
|
-
"vue": "^3.5.
|
|
45
|
+
"vue": "^3.5.21"
|
|
46
46
|
},
|
|
47
47
|
"publishConfig": {
|
|
48
48
|
"access": "public"
|