mvw-search-index 2.3.0 → 2.3.5

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.
Files changed (3) hide show
  1. package/README.md +82 -38
  2. package/package.json +16 -17
  3. package/package-lock.json +0 -5203
package/README.md CHANGED
@@ -1,43 +1,58 @@
1
- # Lunr Search Index
1
+ # mvw-search-index
2
2
 
3
3
  [![Build State](https://github.com/Tiliavir/mvw-search-index/workflows/Node%20CI/badge.svg)](https://github.com/Tiliavir/mvw-search-index/actions)
4
4
  [![NPM version](https://img.shields.io/npm/v/mvw-search-index.svg?style=flat)](https://www.npmjs.com/package/mvw-search-index)
5
+ [![license](https://img.shields.io/npm/l/mvw-search-index.svg)](https://github.com/Tiliavir/mvw-search-index/blob/main/LICENSE)
6
+
7
+ ---
5
8
 
6
9
  ## About
7
10
 
8
- Small module to generate a [lunr](http://lunrjs.com/) index with result store.
11
+ **mvw-search-index** is a lightweight tool for generating a [lunr](http://lunrjs.com/) search index with a result store.
9
12
 
10
- Can e.g. be used to generate a search index for a static website, generated with hugo, jekyll, gatsby or manually.
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
- ## Usage
15
+ ---
16
+
17
+ ## Table of Contents
13
18
 
14
- First you have to install this package, then create the index that you use on e.g. a search page. Find samples for
15
- everything in the following chapters.
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
- ### Installation
27
+ ---
18
28
 
19
- Use `npm install --save-dev mvw-search-index` to add the dependency to your `package.json`.
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
- ### Index creation
37
+ ---
22
38
 
23
- There are multiple possibilities to generate the script. Some are demonstrated in the following sub chapters:
39
+ ## Usage
24
40
 
25
- - From CLI
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
- #### From CLI
43
+ ### From CLI
30
44
 
31
45
  ```bash
32
46
  mvw-search-index <glob> <destination> [css-selector]
33
47
  ```
34
48
 
35
- For example:
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 e.g. for a hugo page (has to be executed after page creation, obviously):
55
+ Or from an npm script:
41
56
 
42
57
  ```json
43
58
  {
@@ -47,44 +62,73 @@ 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
- #### From TypeScript
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
- let index = SearchIndex.createFromHtml(files, bodySelector);
56
- // or: let index = SearchIndex.createFromInfo(info);
57
- // or: let index = SearchIndex.createFromGlob(glob, bodySelector, cb);
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 node.js
81
+ ### From Node.js
63
82
 
64
83
  ```js
65
84
  "use strict";
66
85
 
67
- const index = require("mvw-search-index");
68
- const fs = require("fs")
86
+ const { SearchIndex } = require("mvw-search-index");
87
+ const fs = require("fs");
69
88
 
70
- index.SearchIndex.createFromGlob("./build/**/*.html",
71
- "main",
72
- (index) => fs.writeFileSync("./static/suche/index.json",
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
- ### Sample usage of the created index
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
- You can run `npm run serve` from this repository to run the sample site contained in [./demo](./demo).
100
+ Start it locally with:
79
101
 
80
- This contains a very basic static website with a search form on the landing page `index.html`.
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
- - 2.2.16: updates dependencies
84
- - 2.2.10: updates dependencies
85
- - 2.2.9: gets rid of vinyl and provides a demo application
86
- - 2.1.4: - 2.1.12: dependency update
87
- - 2.1.3: added support of glob on API
88
- - 2.1.1: added CLI
89
- - 2.1.0: renamed `referencedFile` to `href`; allowing to parse HTML files directly
90
- - 2.0: Reason for major release: API break due to update to lunr 2.0.
111
+
112
+ - **2.3.2**: Dependency updates.
113
+ - **2.3.0**: Added attribute support for metadata extraction.
114
+ - **2.2.10 - 2.2.16**: Dependency updates.
115
+ - **2.2.9**: Removed `vinyl`; introduced demo application.
116
+ - **2.1.4 – 2.1.12**: Dependency updates.
117
+ - **2.1.3**: Added glob pattern support to the API.
118
+ - **2.1.1**: Introduced CLI.
119
+ - **2.1.0**: Renamed `referencedFile` to `href`; added direct HTML file parsing.
120
+ - **2.0.0**: **Breaking change** — updated to lunr 2.0.
121
+
122
+ ---
123
+
124
+ ## License
125
+
126
+ This project is licensed under the [MIT License](LICENSE).
127
+
128
+ ---
129
+
130
+ ## Author
131
+
132
+ Maintained by [Tiliavir](https://github.com/Tiliavir).
133
+
134
+ ---
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mvw-search-index",
3
- "version": "2.3.0",
3
+ "version": "2.3.5",
4
4
  "description": "Module to generate the search index using lunr.",
5
5
  "keywords": [
6
6
  "website",
@@ -23,29 +23,28 @@
23
23
  "main": "js/index.js",
24
24
  "types": "js/index.d.ts",
25
25
  "devDependencies": {
26
- "@types/cheerio": "0.22.35",
27
- "@types/jasmine": "5.1.4",
26
+ "@types/cheerio": "1.0.0 ",
27
+ "@types/jasmine": "6.0.0",
28
28
  "@types/lunr": "2.3.7",
29
- "@types/node": "22.4.0",
30
- "@typescript-eslint/eslint-plugin": "8.1.0",
31
- "@typescript-eslint/parser": "8.1.0",
32
- "jasmine": "5.2.0",
33
- "eslint": "9.9.0",
34
- "typescript": "5.5.4",
35
- "serve": "^14.2.3",
36
- "npm-check-updates": "^17.0.6"
29
+ "@types/node": "25.2.3",
30
+ "@typescript-eslint/eslint-plugin": "8.55.0",
31
+ "@typescript-eslint/parser": "8.55.0",
32
+ "jasmine": "6.0.0",
33
+ "eslint": "9.39.2",
34
+ "typescript": "5.9.3",
35
+ "serve": "14.2.5"
37
36
  },
38
37
  "dependencies": {
39
- "cheerio": "~1.0.0",
40
- "commander": "~12.1.0",
41
- "glob": "~11.0.0",
42
- "lunr": "~2.3.9"
38
+ "cheerio": "1.2.0",
39
+ "commander": "14.0.3",
40
+ "glob": "13.0.3",
41
+ "lunr": "2.3.9"
43
42
  },
44
43
  "scripts": {
45
44
  "build": "tsc -p ./ts",
46
45
  "test": "npx eslint . && npm run build && tsc -p ./spec && jasmine",
47
- "preserve": "cd demo && node ../js/cli.js './**/*.html' index.json 'body.to-be-indexed'",
48
- "serve": "serve ./demo"
46
+ "preserve": "cd docs && node ../js/cli.js './**/*.html' index.json 'body.to-be-indexed'",
47
+ "serve": "serve docs"
49
48
  },
50
49
  "repository": {
51
50
  "type": "git",