@vuepress-plume/plugin-search 1.0.0-rc.194 → 1.0.0-rc.195
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.
- package/lib/node/index.js +1 -61
- package/package.json +1 -1
package/lib/node/index.js
CHANGED
|
@@ -100,54 +100,7 @@ async function prepareSearchIndex({ app, isSearchable, searchOptions }) {
|
|
|
100
100
|
}
|
|
101
101
|
if (app.env.isDebug) logger.info(`\n[${colors.green("@vuepress-plume/plugin-search")}] prepare search time spent: ${(performance.now() - start).toFixed(2)}ms`);
|
|
102
102
|
}
|
|
103
|
-
|
|
104
|
-
async function queueUpdateIndexFile({ page, isSearchable, searchOptions }) {
|
|
105
|
-
updateQueue = updateQueue.then(() => indexFile(page, searchOptions, isSearchable));
|
|
106
|
-
return updateQueue;
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Handle search index update when a page is modified.
|
|
110
|
-
*
|
|
111
|
-
* 当页面被修改时处理搜索索引更新。
|
|
112
|
-
*
|
|
113
|
-
* @param app - VuePress application instance / VuePress 应用实例
|
|
114
|
-
* @param options - Search index preparation options / 搜索索引准备选项
|
|
115
|
-
* @param options.page - VuePress page instance / VuePress 页面实例
|
|
116
|
-
* @param options.isSearchable - Function to filter searchable pages / 过滤可搜索页面的函数
|
|
117
|
-
* @param options.searchOptions - MiniSearch configuration / MiniSearch 配置
|
|
118
|
-
*/
|
|
119
|
-
async function onSearchIndexUpdated(app, { page, isSearchable, searchOptions }) {
|
|
120
|
-
if (isSearchable && !isSearchable(page)) return;
|
|
121
|
-
await queueUpdateIndexFile({
|
|
122
|
-
page,
|
|
123
|
-
isSearchable,
|
|
124
|
-
searchOptions
|
|
125
|
-
});
|
|
126
|
-
await writeTemp(app);
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Handle search index update when a page is removed.
|
|
130
|
-
*
|
|
131
|
-
* 当页面被删除时处理搜索索引更新。
|
|
132
|
-
*
|
|
133
|
-
* @param app - VuePress application instance / VuePress 应用实例
|
|
134
|
-
* @param options - Search index preparation options / 搜索索引准备选项
|
|
135
|
-
* @param options.page - VuePress page instance / VuePress 页面实例
|
|
136
|
-
* @param options.isSearchable - Function to filter searchable pages / 过滤可搜索页面的函数
|
|
137
|
-
* @param options.searchOptions - MiniSearch configuration / MiniSearch 配置
|
|
138
|
-
*/
|
|
139
|
-
async function onSearchIndexRemoved(app, { page, isSearchable, searchOptions }) {
|
|
140
|
-
if (isSearchable && !isSearchable(page)) return;
|
|
141
|
-
if (page.filePathRelative) {
|
|
142
|
-
const fileId = page.path;
|
|
143
|
-
const locale = page.pathLocale;
|
|
144
|
-
const lang = page.lang;
|
|
145
|
-
const index = getIndexByLocale(locale, lang, searchOptions);
|
|
146
|
-
const cache = getIndexCache(fileId);
|
|
147
|
-
if (cache && cache.length) index.removeAll(cache);
|
|
148
|
-
await writeTemp(app);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
103
|
+
Promise.resolve();
|
|
151
104
|
/**
|
|
152
105
|
* Write all search indexes to temporary files.
|
|
153
106
|
*
|
|
@@ -501,19 +454,6 @@ function searchPlugin({ locales = {}, isSearchable, ...searchOptions } = {}) {
|
|
|
501
454
|
searchOptions
|
|
502
455
|
});
|
|
503
456
|
}
|
|
504
|
-
},
|
|
505
|
-
onPageUpdated: async (app, type, page) => {
|
|
506
|
-
if (!page?.filePathRelative) return;
|
|
507
|
-
if (type === "create" || type === "update") await onSearchIndexUpdated(app, {
|
|
508
|
-
page,
|
|
509
|
-
isSearchable,
|
|
510
|
-
searchOptions
|
|
511
|
-
});
|
|
512
|
-
else if (type === "delete") await onSearchIndexRemoved(app, {
|
|
513
|
-
page,
|
|
514
|
-
isSearchable,
|
|
515
|
-
searchOptions
|
|
516
|
-
});
|
|
517
457
|
}
|
|
518
458
|
});
|
|
519
459
|
}
|
package/package.json
CHANGED