-
Notifications
You must be signed in to change notification settings - Fork 376
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
save re-run yarn
- Loading branch information
Showing
4 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
generator/konfig-next-app/src/utils/compute-search-index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { OpenAPIV3_XDocument } from 'konfig-lib' | ||
import Fuse from 'fuse.js' | ||
|
||
/** | ||
* Computes a search index using flexsearch | ||
*/ | ||
export function computeSearchIndex({ | ||
markdown, | ||
openapi, | ||
}: { | ||
markdown: { id: string; content: string }[] | ||
openapi: OpenAPIV3_XDocument | ||
}) { | ||
const fuse = new Fuse(markdown, { keys: ['id', 'content'] }) | ||
const myIndex = Fuse.createIndex(['id', 'content'], markdown) | ||
console.log(console.log(JSON.stringify(myIndex.toJSON(), null, 2))) | ||
const results = fuse.search('Welcome to the SnapTrade developer hub') | ||
console.log(results.length) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3088,6 +3088,11 @@ functions-have-names@^1.2.2, functions-have-names@^1.2.3: | |
resolved "https://registry.yarnpkg.com/functions-have-names/-/functions-have-names-1.2.3.tgz#0404fe4ee2ba2f607f0e0ec3c80bae994133b834" | ||
integrity sha512-xckBUXyTIqT97tq2x2AMb+g163b5JFysYk0x4qxNFwbfQkmNZoiRHb6sPzI9/QV33WeuvVYBUIiD4NzNIyqaRQ== | ||
|
||
fuse.js@^6.6.2: | ||
version "6.6.2" | ||
resolved "https://registry.yarnpkg.com/fuse.js/-/fuse.js-6.6.2.tgz#fe463fed4b98c0226ac3da2856a415576dc9a111" | ||
integrity sha512-cJaJkxCCxC8qIIcPBF9yGxY0W/tVZS3uEISDxhYIdtk8OL93pe+6Zj7LjCqVV4dzbqcriOZ+kQ/NE4RXZHsIGA== | ||
|
||
[email protected]: | ||
version "3.9.0" | ||
resolved "https://registry.yarnpkg.com/generic-pool/-/generic-pool-3.9.0.tgz#36f4a678e963f4fdb8707eab050823abc4e8f5e4" | ||
|