diff options
author | Shotaro Aoki <ikoamu@gmail.com> | 2024-09-16 00:10:50 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-16 00:10:50 +0900 |
commit | ce8a263fa24644083ba7be508b6f6916b5f2b9a5 (patch) | |
tree | eebd6291b1416916cac3c13e76a99646358f4f82 | |
parent | 3a618f8defb382a76e19c9255bb60262e12421f1 (diff) | |
parent | 2c6f5c08beaa73b9d166370a605f9b505f29b480 (diff) |
Merge pull request #26 from thargosu/fuse_index
Fuse index
-rw-r--r-- | .gitignore | 5 | ||||
-rw-r--r-- | action.yml | 8 | ||||
-rw-r--r-- | build-index.js | 11 | ||||
-rwxr-xr-x | local.sh | 6 | ||||
-rw-r--r-- | package-lock.json | 54 | ||||
-rw-r--r-- | package.json | 1 |
6 files changed, 70 insertions, 15 deletions
@@ -4,4 +4,7 @@ graphdata.json searchdata.json notes/ org-roam-ui/ -out/
\ No newline at end of file +out/ + +# Fuse.js index +fuse-index.json @@ -72,6 +72,14 @@ runs: working-directory: action run: cp --force searchdata.json ../ui/components/Search/ shell: bash + - name: Create Search index + working-directory: action + run: node build-index.js + shell: bash + - name: Copy fuse-index.json to ../ui/components/Search + working-directory: action + run: cp --force fuse-index.json ../ui/components/Search/ + shell: bash - name: Copy org/img to ui/public/ working-directory: action run: | diff --git a/build-index.js b/build-index.js new file mode 100644 index 0000000..e8a8bae --- /dev/null +++ b/build-index.js @@ -0,0 +1,11 @@ +// build-index.js + +const Fuse = require('fuse.js') +const fs = require('fs') +const data = require('./searchdata.json') + +// Create the Fuse index +const myIndex = Fuse.createIndex(['tags', 'title', 'content'], data) + +// Serialize and save it +fs.writeFileSync('fuse-index.json', JSON.stringify(myIndex.toJSON())) @@ -15,9 +15,13 @@ npm install npm run generate:graphdata --script_params=$ROAM_DB_PATH ./create_notes.sh $ROAM_PATH npm run generate:search +npm install fuse.js +node build-index.js # Copy files to the org-roam-ui directory cp -f searchdata.json org-roam-ui/components/Search/ +cp -f fuse-index.json org-roam-ui/components/Search/ + if [ -d $ROAM_IMG_PATH ]; then cp -r $ROAM_IMG_PATH org-roam-ui/public fi @@ -31,4 +35,4 @@ if [ -d "../../out" ]; then fi mv out ../../ popd -popd
\ No newline at end of file +popd diff --git a/package-lock.json b/package-lock.json index ac10db0..59bc553 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,6 +9,7 @@ "version": "1.0.0", "license": "ISC", "dependencies": { + "fuse.js": "^7.0.0", "orgast-util-to-string": "^1.0.1", "sqlite3": "^5.1.7", "unified": "^11.0.4", @@ -434,6 +435,14 @@ "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", "optional": true }, + "node_modules/fuse.js": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/fuse.js/-/fuse.js-7.0.0.tgz", + "integrity": "sha512-14F4hBIxqKvD4Zz/XjDc3y94mNZN6pRv3U13Udo0lNLCWRBUsrMv2xwcF/y/Z5sV6+FQW+/ow68cHpm4sunt8Q==", + "engines": { + "node": ">=10" + } + }, "node_modules/gauge": { "version": "4.0.4", "resolved": "https://registry.npmjs.org/gauge/-/gauge-4.0.4.tgz", @@ -607,11 +616,18 @@ "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz", "integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==" }, - "node_modules/ip": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ip/-/ip-2.0.0.tgz", - "integrity": "sha512-WKa+XuLG1A1R0UWhl2+1XQSi+fZWMsYKffMZTTYsiZaUD8k2yDAj5atimTUD2TZkyCkNEeYE5NhFZmupOGtjYQ==", - "optional": true + "node_modules/ip-address": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/ip-address/-/ip-address-9.0.5.tgz", + "integrity": "sha512-zHtQzGojZXTwZTHQqra+ETKd4Sn3vgi7uBmlPoXVWZqYvuKmtI0l/VZTjqGmJY9x88GGOaZ9+G9ES8hC4T4X8g==", + "optional": true, + "dependencies": { + "jsbn": "1.1.0", + "sprintf-js": "^1.1.3" + }, + "engines": { + "node": ">= 12" + } }, "node_modules/is-fullwidth-code-point": { "version": "3.0.0", @@ -645,6 +661,12 @@ "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", "optional": true }, + "node_modules/jsbn": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-1.1.0.tgz", + "integrity": "sha512-4bYVV3aAMtDTTu4+xsDYa6sy9GyJ69/amsu9sYF2zqjiEoZA5xJi3BrfX3uY+/IekIu7MwdObdbDWpoZdBv3/A==", + "optional": true + }, "node_modules/lru-cache": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", @@ -1157,16 +1179,16 @@ } }, "node_modules/socks": { - "version": "2.7.1", - "resolved": "https://registry.npmjs.org/socks/-/socks-2.7.1.tgz", - "integrity": "sha512-7maUZy1N7uo6+WVEX6psASxtNlKaNVMlGQKkG/63nEDdLOWNbiUMoLK7X4uYoLhQstau72mLgfEWcXcwsaHbYQ==", + "version": "2.8.3", + "resolved": "https://registry.npmjs.org/socks/-/socks-2.8.3.tgz", + "integrity": "sha512-l5x7VUUWbjVFbafGLxPWkYsHIhEvmF85tbIeFZWc8ZPtoMyybuEhL7Jye/ooC4/d48FgOjSJXgsF/AJPYCW8Zw==", "optional": true, "dependencies": { - "ip": "^2.0.0", + "ip-address": "^9.0.5", "smart-buffer": "^4.2.0" }, "engines": { - "node": ">= 10.13.0", + "node": ">= 10.0.0", "npm": ">= 3.0.0" } }, @@ -1184,6 +1206,12 @@ "node": ">= 10" } }, + "node_modules/sprintf-js": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.1.3.tgz", + "integrity": "sha512-Oo+0REFV59/rz3gfJNKQiBlwfHaSESl1pcGyABQsnnIfWOFt6JNj5gCog2U6MLZ//IGYD+nA8nI+mTShREReaA==", + "optional": true + }, "node_modules/sqlite3": { "version": "5.1.7", "resolved": "https://registry.npmjs.org/sqlite3/-/sqlite3-5.1.7.tgz", @@ -1262,9 +1290,9 @@ } }, "node_modules/tar": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/tar/-/tar-6.2.0.tgz", - "integrity": "sha512-/Wo7DcT0u5HUV486xg675HtjNd3BXZ6xDbzsCUZPt5iw8bTQ63bP0Raut3mvro9u+CUyq7YQd8Cx55fsZXxqLQ==", + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/tar/-/tar-6.2.1.tgz", + "integrity": "sha512-DZ4yORTwrbTj/7MZYq2w+/ZFdI6OZ/f9SFHR+71gIVUZhOQPHzVCLpvRnPgyaMpfWxxk/4ONva3GQSyNIKRv6A==", "dependencies": { "chownr": "^2.0.0", "fs-minipass": "^2.0.0", diff --git a/package.json b/package.json index 44e9bf3..735367d 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "author": "", "license": "ISC", "dependencies": { + "fuse.js": "^7.0.0", "orgast-util-to-string": "^1.0.1", "sqlite3": "^5.1.7", "unified": "^11.0.4", |