Skip to content

Commit

Permalink
Merge pull request #26 from thargosu/fuse_index
Browse files Browse the repository at this point in the history
Fuse index
  • Loading branch information
ikoamu authored Sep 15, 2024
2 parents 3a618f8 + 2c6f5c0 commit ce8a263
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 15 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@ graphdata.json
searchdata.json
notes/
org-roam-ui/
out/
out/

# Fuse.js index
fuse-index.json
8 changes: 8 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
11 changes: 11 additions & 0 deletions build-index.js
Original file line number Diff line number Diff line change
@@ -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()))
6 changes: 5 additions & 1 deletion local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -31,4 +35,4 @@ if [ -d "../../out" ]; then
fi
mv out ../../
popd
popd
popd
54 changes: 41 additions & 13 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit ce8a263

Please sign in to comment.