@vuepress-plume/plugin-search 1.0.0-rc.162 → 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
- const locale = computed(() => localesRef.value[routeLocale.value] ?? defaultLocales[routeLocale.value] ?? defaultLocales["/"]);
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
- const pages = isSearchable ? app.pages.filter(isSearchable) : app.pages;
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
- const pages = isSearchable ? app.pages.filter(isSearchable) : app.pages;
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 localeName = locale.replace(/^\/|\/$/g, "").replace(/\//g, "_") || "default";
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.162",
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",