diff options
-rw-r--r-- | .gitignore | 5 | ||||
-rw-r--r-- | action.yml | 8 | ||||
-rw-r--r-- | build-index.js | 11 | ||||
-rwxr-xr-x | local.sh | 9 | ||||
-rw-r--r-- | package-lock.json | 9 | ||||
-rw-r--r-- | package.json | 1 |
6 files changed, 39 insertions, 4 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())) @@ -1,8 +1,7 @@ #!/bin/bash -# export ROAM_PATH=/path/to/org-roam/src -# export ROAM_DB_FILE=org-roam.db - +read -p "Enter the ROAM_PATH: " ROAM_PATH +read -p "Enter the ROAM_DB_FILE: " ROAM_DB_FILE ROAM_DB_PATH=$ROAM_PATH/$ROAM_DB_FILE ROAM_IMG_PATH=$ROAM_PATH/img @@ -16,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 diff --git a/package-lock.json b/package-lock.json index fdffa2d..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", 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", |