-
Notifications
You must be signed in to change notification settings - Fork 135
Expose Node.js API #72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Could I register a vote for the nodejs API to support passing files on disk, but also passing actual entries to add to the index instead of HTML to be parsed? If you want to customize how an HTML document is turned into search results (or in my case, already have all that customization built), a node.js API that allowed adding individual results would make pagefind super useful. Folks would still be able to wire up pagefind's indexing and frontend bits, and could still use the CLI to generate indexes if they were starting from scratch, but if they wanted to customize it'd be super powerful to programmatically build up the index! |
Good suggestion @airhorns — I might spin that up as a separate issue after implementing the simple version of the API. To start with, the API will be setting CLI flags and running the Pagefind binary. To support adding entries I'll probably need to expand on the JS↔Binary communication for a nice way to pass in entries, since they don't really fit as CLI flags. |
An update for anyone following the issue — work for this is underway. (Including passing actual entries @airhorns 👀). Sample: import * as pagefind from "pagefind";
const { errors, index } = await pagefind.createIndex({ /* opts */ });
await index.addFile("testing/index.html", "<html><body><h1>Testing, testing</h1></body></html>");
await index.writeFiles({ /* opts */ }); Still to come: |
Awesome, can't wait :) |
Hey all ! 👋 Good news — this has landed in Pagefind v1.0.0! ✨ See the full release notes here: https://github.com/CloudCannon/pagefind/releases/tag/v1.0.0 💙 See the library guide here: https://pagefind.app/docs/node-api/ |
Add support for using the npm
pagefind
package via node as discussed in #71The text was updated successfully, but these errors were encountered: