mvw-search-index 2.2.18 → 2.3.2
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/README.md +81 -38
- package/eslint.config.mjs +15 -0
- package/js/index.d.ts +0 -1
- package/package-lock.json +3208 -7919
- package/package.json +17 -18
- package/.eslintrc.js +0 -11
package/README.md
CHANGED
|
@@ -1,43 +1,58 @@
|
|
|
1
|
-
#
|
|
1
|
+
# mvw-search-index
|
|
2
2
|
|
|
3
3
|
[](https://github.com/Tiliavir/mvw-search-index/actions)
|
|
4
4
|
[](https://www.npmjs.com/package/mvw-search-index)
|
|
5
|
+
[](https://github.com/Tiliavir/mvw-search-index/blob/main/LICENSE)
|
|
6
|
+
|
|
7
|
+
---
|
|
5
8
|
|
|
6
9
|
## About
|
|
7
10
|
|
|
8
|
-
|
|
11
|
+
**mvw-search-index** is a lightweight tool for generating a [lunr](http://lunrjs.com/) search index with a result store.
|
|
9
12
|
|
|
10
|
-
|
|
13
|
+
It is ideal for adding fast client-side search capabilities to static websites — whether built with Hugo, Jekyll, Gatsby, or even manually.
|
|
11
14
|
|
|
12
|
-
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Table of Contents
|
|
13
18
|
|
|
14
|
-
|
|
15
|
-
|
|
19
|
+
- [Installation](#installation)
|
|
20
|
+
- [Usage](#usage)
|
|
21
|
+
- [From CLI](#from-cli)
|
|
22
|
+
- [From TypeScript](#from-typescript)
|
|
23
|
+
- [From Node.js](#from-nodejs)
|
|
24
|
+
- [Demo](#demo)
|
|
25
|
+
- [Releases](#releases)
|
|
16
26
|
|
|
17
|
-
|
|
27
|
+
---
|
|
18
28
|
|
|
19
|
-
|
|
29
|
+
## Installation
|
|
30
|
+
|
|
31
|
+
Add the package to your project:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
npm install --save-dev mvw-search-index
|
|
35
|
+
```
|
|
20
36
|
|
|
21
|
-
|
|
37
|
+
---
|
|
22
38
|
|
|
23
|
-
|
|
39
|
+
## Usage
|
|
24
40
|
|
|
25
|
-
-
|
|
26
|
-
- From TypeScript
|
|
27
|
-
- From nodejs
|
|
41
|
+
You can create an index using the command-line interface, directly from TypeScript, or through Node.js.
|
|
28
42
|
|
|
29
|
-
|
|
43
|
+
### From CLI
|
|
30
44
|
|
|
31
45
|
```bash
|
|
32
46
|
mvw-search-index <glob> <destination> [css-selector]
|
|
33
47
|
```
|
|
34
48
|
|
|
35
|
-
|
|
49
|
+
Example:
|
|
50
|
+
|
|
36
51
|
```bash
|
|
37
52
|
mvw-search-index ./build/**/*.html ./build/index.json
|
|
38
53
|
```
|
|
39
54
|
|
|
40
|
-
Or from an npm script
|
|
55
|
+
Or from an npm script:
|
|
41
56
|
|
|
42
57
|
```json
|
|
43
58
|
{
|
|
@@ -47,44 +62,72 @@ Or from an npm script e.g. for a hugo page (has to be executed after page creati
|
|
|
47
62
|
}
|
|
48
63
|
```
|
|
49
64
|
|
|
50
|
-
|
|
65
|
+
> Ensure the indexing step runs after the site is built.
|
|
66
|
+
|
|
67
|
+
### From TypeScript
|
|
51
68
|
|
|
52
69
|
```ts
|
|
53
70
|
import { SearchIndex } from "mvw-search-index";
|
|
71
|
+
import * as fs from "fs";
|
|
54
72
|
|
|
55
|
-
|
|
56
|
-
//
|
|
57
|
-
//
|
|
73
|
+
const index = SearchIndex.createFromHtml(files, bodySelector);
|
|
74
|
+
// Alternatives:
|
|
75
|
+
// const index = SearchIndex.createFromInfo(info);
|
|
76
|
+
// const index = SearchIndex.createFromGlob(glob, bodySelector, callback);
|
|
58
77
|
|
|
59
78
|
fs.writeFileSync("index.json", JSON.stringify(index));
|
|
60
79
|
```
|
|
61
80
|
|
|
62
|
-
### From
|
|
81
|
+
### From Node.js
|
|
63
82
|
|
|
64
83
|
```js
|
|
65
84
|
"use strict";
|
|
66
85
|
|
|
67
|
-
const
|
|
68
|
-
const fs = require("fs")
|
|
86
|
+
const { SearchIndex } = require("mvw-search-index");
|
|
87
|
+
const fs = require("fs");
|
|
69
88
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
JSON.stringify(index)));
|
|
89
|
+
SearchIndex.createFromGlob("./build/**/*.html", "main", (index) => {
|
|
90
|
+
fs.writeFileSync("./static/suche/index.json", JSON.stringify(index));
|
|
91
|
+
});
|
|
74
92
|
```
|
|
75
93
|
|
|
76
|
-
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## Demo
|
|
97
|
+
|
|
98
|
+
A basic sample site is included and served from [GitHub Pages](https://www.tiliavir.github.io/mvw-search-index).
|
|
77
99
|
|
|
78
|
-
|
|
100
|
+
Start it locally with:
|
|
79
101
|
|
|
80
|
-
|
|
102
|
+
```bash
|
|
103
|
+
npm run serve
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
This serves the content from [./docs](docs), featuring a simple static site with a search form on `index.html`.
|
|
107
|
+
|
|
108
|
+
---
|
|
81
109
|
|
|
82
110
|
## Releases
|
|
83
|
-
|
|
84
|
-
- 2.
|
|
85
|
-
- 2.2.
|
|
86
|
-
- 2.
|
|
87
|
-
- 2.1.
|
|
88
|
-
- 2.1.
|
|
89
|
-
- 2.1.
|
|
90
|
-
- 2.0
|
|
111
|
+
|
|
112
|
+
- **2.3.0**: Added attribute support for metadata extraction.
|
|
113
|
+
- **2.2.10 - 2.2.16**: Dependency updates.
|
|
114
|
+
- **2.2.9**: Removed `vinyl`; introduced demo application.
|
|
115
|
+
- **2.1.4 – 2.1.12**: Dependency updates.
|
|
116
|
+
- **2.1.3**: Added glob pattern support to the API.
|
|
117
|
+
- **2.1.1**: Introduced CLI.
|
|
118
|
+
- **2.1.0**: Renamed `referencedFile` to `href`; added direct HTML file parsing.
|
|
119
|
+
- **2.0.0**: **Breaking change** — updated to lunr 2.0.
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
## License
|
|
124
|
+
|
|
125
|
+
This project is licensed under the [MIT License](LICENSE).
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## Author
|
|
130
|
+
|
|
131
|
+
Maintained by [Tiliavir](https://github.com/Tiliavir).
|
|
132
|
+
|
|
133
|
+
---
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import tsEsLint from "@typescript-eslint/eslint-plugin";
|
|
2
|
+
import tsParser from "@typescript-eslint/parser";
|
|
3
|
+
|
|
4
|
+
export default [
|
|
5
|
+
{
|
|
6
|
+
files: ["**/*.ts"],
|
|
7
|
+
plugins: {
|
|
8
|
+
"@typescript-eslint": tsEsLint,
|
|
9
|
+
},
|
|
10
|
+
|
|
11
|
+
languageOptions: {
|
|
12
|
+
parser: tsParser,
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
];
|
package/js/index.d.ts
CHANGED