Astro plugin
The plugin-astro plugin allows you to index the content of your Astro websites and offer text search to your visitors.
Installation
You can install the plugin using any major Node.js package manager.
Usage
There are two main aspects to consider when using this plugin:
- DB generation
- Loading DBs & performing searches
When running the astro build
command, a new DB file will be persisted in the dist/assets
directory. For the particular case of this example, it will be saved in the file dist/assets/oramaDB_mydb.json
.
Local development
Running Astro with astro dev
does not bundle the assets, including Orama’s DBs, causing a “404 - not found” error when trying to load them.
In order to use Orama in local Astro development, you can run astro build
to build your project and then astro preview
to serve the built files in the dist/
folder.
Loading the DB on client-side
To use the generated DBs in your pages, you can include a script in your <head>
section, as the following one:
For now, the plugin only expose load & search functionality on the client side, but we might expose other Orama features as soon as we stabilise some internal details and public APIs.