@vuepress-plume/plugin-search 1.0.0-rc.193 → 1.0.0-rc.194
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 +13 -2
- package/package.json +2 -2
package/lib/node/index.js
CHANGED
|
@@ -100,6 +100,11 @@ 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
|
+
let updateQueue = Promise.resolve();
|
|
104
|
+
async function queueUpdateIndexFile({ page, isSearchable, searchOptions }) {
|
|
105
|
+
updateQueue = updateQueue.then(() => indexFile(page, searchOptions, isSearchable));
|
|
106
|
+
return updateQueue;
|
|
107
|
+
}
|
|
103
108
|
/**
|
|
104
109
|
* Handle search index update when a page is modified.
|
|
105
110
|
*
|
|
@@ -113,7 +118,11 @@ async function prepareSearchIndex({ app, isSearchable, searchOptions }) {
|
|
|
113
118
|
*/
|
|
114
119
|
async function onSearchIndexUpdated(app, { page, isSearchable, searchOptions }) {
|
|
115
120
|
if (isSearchable && !isSearchable(page)) return;
|
|
116
|
-
await
|
|
121
|
+
await queueUpdateIndexFile({
|
|
122
|
+
page,
|
|
123
|
+
isSearchable,
|
|
124
|
+
searchOptions
|
|
125
|
+
});
|
|
117
126
|
await writeTemp(app);
|
|
118
127
|
}
|
|
119
128
|
/**
|
|
@@ -189,7 +198,9 @@ async function indexFile(page, options, isSearchable) {
|
|
|
189
198
|
const cache = getIndexCache(fileId);
|
|
190
199
|
const sections = splitPageIntoSections(`<h1><a href="#"><span>${page.frontmatter.title || page.title}</span></a></h1>
|
|
191
200
|
${page.contentRendered}`);
|
|
192
|
-
|
|
201
|
+
try {
|
|
202
|
+
if (cache && cache.length) index.removeAll(cache);
|
|
203
|
+
} catch {}
|
|
193
204
|
for await (const section of sections) {
|
|
194
205
|
if (!section || !(section.text || section.titles)) break;
|
|
195
206
|
const { anchor, text, titles } = section;
|
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.194",
|
|
5
5
|
"description": "The Plugin for VuePress 2 - local search",
|
|
6
6
|
"author": "pengzhanbo <volodymyr@foxmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"mark.js": "^8.11.1",
|
|
43
43
|
"minisearch": "^7.2.0",
|
|
44
44
|
"p-map": "^7.0.4",
|
|
45
|
-
"vue": "^3.5.
|
|
45
|
+
"vue": "^3.5.32"
|
|
46
46
|
},
|
|
47
47
|
"publishConfig": {
|
|
48
48
|
"access": "public",
|