aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--action.yml10
-rw-r--r--generate_searchdata.mjs39
-rw-r--r--package-lock.json167
-rw-r--r--package.json9
5 files changed, 222 insertions, 4 deletions
diff --git a/.gitignore b/.gitignore
index 5652e4e..d22afe2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,5 @@
node_modules/
DS_Store
graphdata.json
+searchdata.json
notes/
diff --git a/action.yml b/action.yml
index 68fccce..89b7bd0 100644
--- a/action.yml
+++ b/action.yml
@@ -58,7 +58,15 @@ runs:
shell: bash
- name: Create Notes
working-directory: action
- run: ./create_notes.sh ../orgs/${{ inputs.org-roam-directory }}
+ run: ./create_notes.sh ../orgs/${{ inputs .org-roam-directory }}
+ shell: bash
+ - name: Create Search data
+ working-directory: action
+ run: npm run generate:search
+ shell: bash
+ - name: Copy seachdata.json to ../ui/components/Search
+ working-directory: action
+ run: cp --force searchdata.json ../ui/components/Search/
shell: bash
- name: Copy org/img to ui/public/
working-directory: action
diff --git a/generate_searchdata.mjs b/generate_searchdata.mjs
new file mode 100644
index 0000000..c226e03
--- /dev/null
+++ b/generate_searchdata.mjs
@@ -0,0 +1,39 @@
+import fs from 'fs';
+import { unified } from 'unified';
+import uniorgParse from 'uniorg-parse';
+import { toString } from 'orgast-util-to-string';
+
+fs.readFile('graphdata.json', 'utf8', (_, data) => {
+ const graphdata = JSON.parse(data);
+ const nodes = graphdata.data.nodes;
+ const processer = unified().use(uniorgParse);
+ const searchData = [];
+
+ fs.readdir('notes', (_, files) => {
+ files.forEach(file => {
+ const org = fs.readFileSync(`notes/${file}`, 'utf8');
+ const tree = processer.parse(org);
+ const filtered = tree.children.filter(
+ node => node.type !== 'property-drawer' && node.type !== 'keyword'
+ );
+ const content = toString({
+ ...tree,
+ children: filtered,
+ });
+ const node = nodes.find(n => n.id === file);
+ if (node) {
+ searchData.push({
+ id: node.id,
+ title: node.title,
+ tags: node.tags[0] ? node.tags : null,
+ content,
+ });
+ }
+ });
+ fs.writeFile('searchdata.json', JSON.stringify(searchData), (err) => {
+ if (err) throw err;
+ console.log('The file has been saved!');
+ });
+ });
+});
+
diff --git a/package-lock.json b/package-lock.json
index 58199c3..ac10db0 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -9,7 +9,11 @@
"version": "1.0.0",
"license": "ISC",
"dependencies": {
- "sqlite3": "^5.1.7"
+ "orgast-util-to-string": "^1.0.1",
+ "sqlite3": "^5.1.7",
+ "unified": "^11.0.4",
+ "uniorg": "^1.1.1",
+ "uniorg-parse": "^2.1.1"
}
},
"node_modules/@gar/promisify": {
@@ -51,6 +55,11 @@
"node": ">= 6"
}
},
+ "node_modules/@types/unist": {
+ "version": "3.0.2",
+ "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.2.tgz",
+ "integrity": "sha512-dqId9J8K/vGi5Zr7oo212BGii5m3q5Hxlkwy3WpYuKPklmBEvsbMYYyLxAQpSffdLl/gdW0XUpKWFvYmyoWCoQ=="
+ },
"node_modules/abbrev": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz",
@@ -122,6 +131,15 @@
"node": "^12.13.0 || ^14.15.0 || >=16.0.0"
}
},
+ "node_modules/bail": {
+ "version": "2.0.2",
+ "resolved": "https://registry.npmjs.org/bail/-/bail-2.0.2.tgz",
+ "integrity": "sha512-0xO6mYd7JB2YesxDKplafRpsiOzPt9V02ddPCLbY1xYGPOX24NTyN50qnUxgCPcSoYMhKpAuBTjQoRZCAkUDRw==",
+ "funding": {
+ "type": "github",
+ "url": "https://github.com/sponsors/wooorm"
+ }
+ },
"node_modules/balanced-match": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
@@ -310,6 +328,14 @@
"integrity": "sha512-bd2L678uiWATM6m5Z1VzNCErI3jiGzt6HGY8OVICs40JQq/HALfbyNJmp0UDakEY4pMMaN0Ly5om/B1VI/+xfQ==",
"optional": true
},
+ "node_modules/dequal": {
+ "version": "2.0.3",
+ "resolved": "https://registry.npmjs.org/dequal/-/dequal-2.0.3.tgz",
+ "integrity": "sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==",
+ "engines": {
+ "node": ">=6"
+ }
+ },
"node_modules/detect-libc": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.0.2.tgz",
@@ -318,6 +344,18 @@
"node": ">=8"
}
},
+ "node_modules/devlop": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/devlop/-/devlop-1.1.0.tgz",
+ "integrity": "sha512-RWmIqhcFf1lRYBvNmr7qTNuyCt/7/ns2jbpp1+PalgE/rDQcBT0fioSMUpJ93irlUhC5hrg4cYqe6U+0ImW0rA==",
+ "dependencies": {
+ "dequal": "^2.0.0"
+ },
+ "funding": {
+ "type": "github",
+ "url": "https://github.com/sponsors/wooorm"
+ }
+ },
"node_modules/emoji-regex": {
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz",
@@ -364,6 +402,11 @@
"node": ">=6"
}
},
+ "node_modules/extend": {
+ "version": "3.0.2",
+ "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz",
+ "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g=="
+ },
"node_modules/file-uri-to-path": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz",
@@ -585,6 +628,17 @@
"integrity": "sha512-z7CMFGNrENq5iFB9Bqo64Xk6Y9sg+epq1myIcdHaGnbMTYOxvzsEtdYqQUylB7LxfkvgrrjP32T6Ywciio9UIQ==",
"optional": true
},
+ "node_modules/is-plain-obj": {
+ "version": "4.1.0",
+ "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-4.1.0.tgz",
+ "integrity": "sha512-+Pgi+vMuUNkJyExiMBt5IlFoMyKnr5zhJ4Uspz58WOhBF5QoIZkFyNHIbBAtHwzVAgk5RtndVNsDRN61/mmDqg==",
+ "engines": {
+ "node": ">=12"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
"node_modules/isexe": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
@@ -865,6 +919,11 @@
"wrappy": "1"
}
},
+ "node_modules/orgast-util-to-string": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/orgast-util-to-string/-/orgast-util-to-string-1.0.1.tgz",
+ "integrity": "sha512-hLNTilq3EPohqNJjguspxlzQRADQ7hpsQHhu5c71NzEBvn3agwbMH3e5dJyYybm7rQytkC8+4LRjLM33QXH06A=="
+ },
"node_modules/p-map": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/p-map/-/p-map-4.0.0.tgz",
@@ -1257,6 +1316,15 @@
"node": ">=8"
}
},
+ "node_modules/trough": {
+ "version": "2.2.0",
+ "resolved": "https://registry.npmjs.org/trough/-/trough-2.2.0.tgz",
+ "integrity": "sha512-tmMpK00BjZiUyVyvrBK7knerNgmgvcV/KLVyuma/SC+TQN167GrMRciANTz09+k3zW8L8t60jWO1GpfkZdjTaw==",
+ "funding": {
+ "type": "github",
+ "url": "https://github.com/sponsors/wooorm"
+ }
+ },
"node_modules/tunnel-agent": {
"version": "0.6.0",
"resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz",
@@ -1268,6 +1336,39 @@
"node": "*"
}
},
+ "node_modules/unified": {
+ "version": "11.0.4",
+ "resolved": "https://registry.npmjs.org/unified/-/unified-11.0.4.tgz",
+ "integrity": "sha512-apMPnyLjAX+ty4OrNap7yumyVAMlKx5IWU2wlzzUdYJO9A8f1p9m/gywF/GM2ZDFcjQPrx59Mc90KwmxsoklxQ==",
+ "dependencies": {
+ "@types/unist": "^3.0.0",
+ "bail": "^2.0.0",
+ "devlop": "^1.0.0",
+ "extend": "^3.0.0",
+ "is-plain-obj": "^4.0.0",
+ "trough": "^2.0.0",
+ "vfile": "^6.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/unified"
+ }
+ },
+ "node_modules/uniorg": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/uniorg/-/uniorg-1.1.1.tgz",
+ "integrity": "sha512-HIEf+3EfyEOyYsY3exU0iMJoAofctRCGV4a7UOZf08VWChm2CjP6Vafdeeo3F/0s1v69RJMKBCLsJt8L8Xl0Og=="
+ },
+ "node_modules/uniorg-parse": {
+ "version": "2.1.1",
+ "resolved": "https://registry.npmjs.org/uniorg-parse/-/uniorg-parse-2.1.1.tgz",
+ "integrity": "sha512-bMCppBMxRivlZTJF+2zs2IiOPzZ2/9+v85LcS2unAsDzZ246mudkqIq6FOlRHonUtVVrztJnjruYRHBCrTIb/w==",
+ "dependencies": {
+ "unist-builder": "4.0.0",
+ "vfile": "6.0.1",
+ "vfile-location": "5.0.2"
+ }
+ },
"node_modules/unique-filename": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/unique-filename/-/unique-filename-1.1.1.tgz",
@@ -1286,11 +1387,75 @@
"imurmurhash": "^0.1.4"
}
},
+ "node_modules/unist-builder": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/unist-builder/-/unist-builder-4.0.0.tgz",
+ "integrity": "sha512-wmRFnH+BLpZnTKpc5L7O67Kac89s9HMrtELpnNaE6TAobq5DTZZs5YaTQfAZBA9bFPECx2uVAPO31c+GVug8mg==",
+ "dependencies": {
+ "@types/unist": "^3.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/unified"
+ }
+ },
+ "node_modules/unist-util-stringify-position": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/unist-util-stringify-position/-/unist-util-stringify-position-4.0.0.tgz",
+ "integrity": "sha512-0ASV06AAoKCDkS2+xw5RXJywruurpbC4JZSm7nr7MOt1ojAzvyyaO+UxZf18j8FCF6kmzCZKcAgN/yu2gm2XgQ==",
+ "dependencies": {
+ "@types/unist": "^3.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/unified"
+ }
+ },
"node_modules/util-deprecate": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
"integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw=="
},
+ "node_modules/vfile": {
+ "version": "6.0.1",
+ "resolved": "https://registry.npmjs.org/vfile/-/vfile-6.0.1.tgz",
+ "integrity": "sha512-1bYqc7pt6NIADBJ98UiG0Bn/CHIVOoZ/IyEkqIruLg0mE1BKzkOXY2D6CSqQIcKqgadppE5lrxgWXJmXd7zZJw==",
+ "dependencies": {
+ "@types/unist": "^3.0.0",
+ "unist-util-stringify-position": "^4.0.0",
+ "vfile-message": "^4.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/unified"
+ }
+ },
+ "node_modules/vfile-location": {
+ "version": "5.0.2",
+ "resolved": "https://registry.npmjs.org/vfile-location/-/vfile-location-5.0.2.tgz",
+ "integrity": "sha512-NXPYyxyBSH7zB5U6+3uDdd6Nybz6o6/od9rk8bp9H8GR3L+cm/fC0uUTbqBmUTnMCUDslAGBOIKNfvvb+gGlDg==",
+ "dependencies": {
+ "@types/unist": "^3.0.0",
+ "vfile": "^6.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/unified"
+ }
+ },
+ "node_modules/vfile-message": {
+ "version": "4.0.2",
+ "resolved": "https://registry.npmjs.org/vfile-message/-/vfile-message-4.0.2.tgz",
+ "integrity": "sha512-jRDZ1IMLttGj41KcZvlrYAaI3CfqpLpfpf+Mfig13viT6NKvRzWZ+lXz0Y5D60w6uJIBAOGq9mSHf0gktF0duw==",
+ "dependencies": {
+ "@types/unist": "^3.0.0",
+ "unist-util-stringify-position": "^4.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/unified"
+ }
+ },
"node_modules/which": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
diff --git a/package.json b/package.json
index cc5a714..53796a3 100644
--- a/package.json
+++ b/package.json
@@ -4,12 +4,17 @@
"version": "1.0.0",
"description": "",
"scripts": {
- "generate": "node ./generate_json.js $npm_config_script_params"
+ "generate": "node ./generate_json.js $npm_config_script_params",
+ "generate:search": "node ./generate_searchdata.mjs"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
- "sqlite3": "^5.1.7"
+ "orgast-util-to-string": "^1.0.1",
+ "sqlite3": "^5.1.7",
+ "unified": "^11.0.4",
+ "uniorg": "^1.1.1",
+ "uniorg-parse": "^2.1.1"
}
}