@easyops-cn/docusaurus-search-local 0.35.0 → 0.36.0
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/CHANGELOG.md +12 -0
- package/dist/server/server/utils/parse.js +6 -1
- package/dist/server/server/utils/postBuildFactory.js +1 -1
- package/dist/server/server/utils/processPluginOptions.js +1 -0
- package/dist/server/server/utils/scanDocuments.js +2 -2
- package/dist/server/server/utils/validateOptions.js +1 -0
- package/dist/types/index.d.ts +6 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [0.36.0](https://github.com/easyops-cn/docusaurus-search-local/compare/v0.35.0...v0.36.0) (2023-09-09)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* added ignoreClasses option to be able to exclude specific content from indexing ([e9f7794](https://github.com/easyops-cn/docusaurus-search-local/commit/e9f7794f48c7af070c377d56bf3b6dbfccf3b9de))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* make tests work on windows ([565199a](https://github.com/easyops-cn/docusaurus-search-local/commit/565199a63760e51f2f5421c8df075aeeb7e54a53))
|
|
16
|
+
|
|
5
17
|
## [0.35.0](https://github.com/easyops-cn/docusaurus-search-local/compare/v0.34.0...v0.35.0) (2023-03-04)
|
|
6
18
|
|
|
7
19
|
|
|
@@ -5,10 +5,15 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const cheerio_1 = tslib_1.__importDefault(require("cheerio"));
|
|
6
6
|
const parseDocument_1 = require("./parseDocument");
|
|
7
7
|
const parsePage_1 = require("./parsePage");
|
|
8
|
-
function parse(html, type, url) {
|
|
8
|
+
function parse(html, type, url, { ignoreCssSelectors }) {
|
|
9
9
|
const $ = cheerio_1.default.load(html);
|
|
10
10
|
// Remove copy buttons from code boxes
|
|
11
11
|
$('div[class^="mdxCodeBlock_"] button').remove();
|
|
12
|
+
if (ignoreCssSelectors) {
|
|
13
|
+
for (const ignoreSelector of ignoreCssSelectors) {
|
|
14
|
+
$(ignoreSelector).remove();
|
|
15
|
+
}
|
|
16
|
+
}
|
|
12
17
|
if (type === "docs") {
|
|
13
18
|
// Remove version badges
|
|
14
19
|
$("span.badge")
|
|
@@ -18,7 +18,7 @@ function postBuildFactory(config, searchIndexFilename) {
|
|
|
18
18
|
(0, debug_1.debugInfo)("parsing documents");
|
|
19
19
|
for (const versionData of data) {
|
|
20
20
|
// Give every index entry a unique id so that the index does not need to store long URLs.
|
|
21
|
-
const allDocuments = yield (0, scanDocuments_1.scanDocuments)(versionData.paths);
|
|
21
|
+
const allDocuments = yield (0, scanDocuments_1.scanDocuments)(versionData.paths, config);
|
|
22
22
|
(0, debug_1.debugInfo)("building index");
|
|
23
23
|
const docsByDirMap = new Map();
|
|
24
24
|
const { searchContextByPaths, hideSearchBarWithNoSearchContext, useAllContextsWithNoSearchContext, } = config;
|
|
@@ -12,6 +12,7 @@ function processPluginOptions(options, { siteDir, siteConfig: { themeConfig }, }
|
|
|
12
12
|
ensureArray(config, "docsDir");
|
|
13
13
|
ensureArray(config, "blogDir");
|
|
14
14
|
ensureArray(config, "ignoreFiles");
|
|
15
|
+
ensureArray(config, "ignoreCssSelectors");
|
|
15
16
|
config.docsRouteBasePath = config.docsRouteBasePath.map((basePath) => basePath.replace(/^\//, ""));
|
|
16
17
|
config.blogRouteBasePath = config.blogRouteBasePath.map((basePath) => basePath.replace(/^\//, ""));
|
|
17
18
|
config.docsDir = config.docsDir.map((dir) => path_1.default.resolve(siteDir, dir));
|
|
@@ -12,7 +12,7 @@ let nextDocId = 0;
|
|
|
12
12
|
const getNextDocId = () => {
|
|
13
13
|
return (nextDocId += 1);
|
|
14
14
|
};
|
|
15
|
-
function scanDocuments(DocInfoWithFilePathList) {
|
|
15
|
+
function scanDocuments(DocInfoWithFilePathList, config) {
|
|
16
16
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
17
17
|
const titleDocuments = [];
|
|
18
18
|
const headingDocuments = [];
|
|
@@ -21,7 +21,7 @@ function scanDocuments(DocInfoWithFilePathList) {
|
|
|
21
21
|
yield Promise.all(DocInfoWithFilePathList.map(({ filePath, url, type }) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
22
22
|
(0, debug_1.debugVerbose)(`parsing %s file %o of %o`, type, path_1.default.relative(process.cwd(), filePath), url);
|
|
23
23
|
const html = yield readFileAsync(filePath, { encoding: "utf8" });
|
|
24
|
-
const { pageTitle, sections, breadcrumb } = (0, parse_1.parse)(html, type, url);
|
|
24
|
+
const { pageTitle, sections, breadcrumb } = (0, parse_1.parse)(html, type, url, config);
|
|
25
25
|
const titleId = getNextDocId();
|
|
26
26
|
titleDocuments.push({
|
|
27
27
|
i: titleId,
|
|
@@ -22,6 +22,7 @@ const schema = utils_validation_1.Joi.object({
|
|
|
22
22
|
searchResultContextMaxLength: utils_validation_1.Joi.number().default(50),
|
|
23
23
|
explicitSearchResultPath: utils_validation_1.Joi.boolean().default(false),
|
|
24
24
|
ignoreFiles: isArrayOfStringsOrRegExpsOrStringOrRegExp.default([]),
|
|
25
|
+
ignoreCssSelectors: isStringOrArrayOfStrings.default([]),
|
|
25
26
|
searchBarShortcut: utils_validation_1.Joi.boolean().default(true),
|
|
26
27
|
searchBarShortcutHint: utils_validation_1.Joi.boolean().default(true),
|
|
27
28
|
searchBarPosition: utils_validation_1.Joi.string().default("auto"),
|
package/dist/types/index.d.ts
CHANGED
|
@@ -103,6 +103,12 @@ export interface PluginOptions {
|
|
|
103
103
|
* @default []
|
|
104
104
|
*/
|
|
105
105
|
ignoreFiles?: string | RegExp | (string | RegExp)[];
|
|
106
|
+
/**
|
|
107
|
+
* A list of css selectors to ignore when indexing each page.
|
|
108
|
+
*
|
|
109
|
+
* @default []
|
|
110
|
+
*/
|
|
111
|
+
ignoreCssSelectors?: string | string[];
|
|
106
112
|
/**
|
|
107
113
|
* Whether to enable keyboard shortcut to focus in search bar.
|
|
108
114
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@easyops-cn/docusaurus-search-local",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.36.0",
|
|
4
4
|
"description": "An offline/local search plugin for Docusaurus v2",
|
|
5
5
|
"repository": "https://github.com/easyops-cn/docusaurus-search-local",
|
|
6
6
|
"homepage": "https://github.com/easyops-cn/docusaurus-search-local",
|