-
Notifications
You must be signed in to change notification settings - Fork 76
feat(plugin-meilisearch): support meilisearch #422
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
Merged
Merged
Changes from all commits
Commits
Show all changes
58 commits
Select commit
Hold shift + click to select a range
f5b77d7
feat(plugin-meilisearch): add code to repo
JQiue 9c9e523
Merge branch 'main' into feat/plugin-meilisearch
Mister-Hope 2885d19
feat: rebuild
Mister-Hope d245da0
chore: tweaks
Mister-Hope 6a989ec
chore: tweaks
Mister-Hope 906d524
chore: fix lockfile
Mister-Hope 2fb5800
chore: tweaks
Mister-Hope dec171e
chore: tweaks
Mister-Hope 457cc8d
feat(plugin-meilisearch): add prerender for button
JQiue fd24404
chore: rename export function name
JQiue eba85f6
docs: add meilisearch docs
JQiue 318ed0e
docs: update meilisearch ico and sidebar config
JQiue 709338b
docs: update meilisearch docs
JQiue fb54621
Merge branch 'main' into feat/plugin-meilisearch
Mister-Hope 2b05d4b
chore: update words
Mister-Hope 9e57b57
feat: add built-in translation
Mister-Hope 84c083a
Merge branch 'main' into feat/plugin-meilisearch
Mister-Hope a65a2b0
chore: tweaks
Mister-Hope edfd72c
feat: add missing locales
Mister-Hope 5aa47ef
Merge branch 'main' into feat/plugin-meilisearch
Mister-Hope ef86220
chore: revert
Mister-Hope 3099787
docs: update docs
Mister-Hope 423cfc9
Merge branch 'main' into feat/plugin-meilisearch
Mister-Hope 314ad29
Merge branch 'main' into feat/plugin-meilisearch
Mister-Hope 5f05095
fix: fix types
Mister-Hope 649bb40
docs: correct docs
Mister-Hope 8e52bc8
Merge branch 'main' into feat/plugin-meilisearch
Mister-Hope 27a4ef0
docs: update docs
JQiue 46c2ef9
docs: update docs
JQiue dcd5732
docs: update docs
JQiue 634d024
Merge branch 'main' into feat/plugin-meilisearch
Mister-Hope c90e161
chore: fix broken lockfile
Mister-Hope 5fa2a2d
Merge branch 'main' into feat/plugin-meilisearch
Mister-Hope 598a850
Merge branch 'main' into feat/plugin-meilisearch
Mister-Hope 3ce90a5
Merge branch 'main' into feat/plugin-meilisearch
Mister-Hope c94c893
style: fix linter
Mister-Hope 599bb80
chore: tweaks
Mister-Hope b4a5ca0
fix: fix bundle issue
Mister-Hope c52045b
chore: tweaks
Mister-Hope 43a36d6
fix: watch routeLocale
Mister-Hope 5f1c3d8
ci: fix lockfile
Mister-Hope 98e543d
fix: fix bugs
Mister-Hope d993c7c
fix: fix vite pack issue
Mister-Hope 399409e
chore: tweaks
Mister-Hope 029b937
fix: fix webpack ssg
Mister-Hope 36877cb
docs: update docs
Mister-Hope 8d37fd7
chore: tweaks
Mister-Hope 8738528
Merge branch 'main' into feat/plugin-meilisearch
Mister-Hope 71ed814
Merge branch 'main' into feat/plugin-meilisearch
Mister-Hope 72c8f40
feat: filter results based on page locale
JQiue fa9a319
docs: update docs
JQiue 11dedde
docs: update docs
JQiue 5ed8ec7
fix: fixed an issue where filters could not be passed to options
JQiue bbc481d
Merge branch 'main' into feat/plugin-meilisearch
Mister-Hope f8fd164
docs: update docs
Mister-Hope d7f4c87
docs: update docs
Mister-Hope c5766d8
docs: tweaks
Mister-Hope 7857601
docs: tweaks
Mister-Hope File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
---|---|---|
|
@@ -52,6 +52,7 @@ | |
"mathjax", | ||
"mdast", | ||
"mdit", | ||
"meilisearch", | ||
"meteorlxy", | ||
"mhchem", | ||
"nord", | ||
|
This file contains hidden or 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 hidden or 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 hidden or 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,274 @@ | ||
--- | ||
icon: https://www.meilisearch.com/favicon.ico | ||
--- | ||
|
||
# meilisearch | ||
|
||
<NpmBadge package="@vuepress/plugin-meilisearch" /> | ||
|
||
Integrate [MeiliSearch](https://www.meilisearch.com/) into VuePress, which can provide search to your documentation site. | ||
|
||
## Usage | ||
|
||
```bash | ||
npm i -D @vuepress/plugin-meilisearch@next | ||
``` | ||
|
||
```ts | ||
import { MeiliSearchPlugin } from '@vuepress/plugin-meilisearch' | ||
|
||
export default { | ||
plugins: [ | ||
meilisearchPlugin({ | ||
// Configuration options | ||
host: '', | ||
apiKey: '', | ||
indexUid: '', | ||
}), | ||
], | ||
} | ||
``` | ||
|
||
## Self-hosting MeiliSearch | ||
|
||
MeiliSearch provides a server program that supports self-deployment options for users with cloud servers. To simplify the process of running MeiliSearch on the server side, you can use Docker for installation and management. | ||
|
||
```sh | ||
docker pull getmeili/meilisearch:latest | ||
``` | ||
|
||
On the first startup, a Master Key will be generated by default. **Do not expose this key**; it should only be used for internal server access, as it grants full operational permissions. | ||
|
||
```sh | ||
docker run -it --rm \ | ||
-p 7700:7700 \ | ||
-v $(pwd)/meili_data:/meili_data \ | ||
getmeili/meilisearch:latest | ||
``` | ||
|
||
> See <https://www.meilisearch.com/docs/guides/misc/docker> | ||
|
||
## Crawling the website | ||
|
||
MeiliSearch provides a Docker crawler to crawl documents. Until then, make sure MeiliSearch is running. | ||
|
||
Here is a sample of crawler configuration, which you should save, modify and pass to the crawler: | ||
|
||
```json | ||
{ | ||
"index_uid": "YOUR_INDEX_NAME", | ||
"start_urls": ["https://YOUR_WEBSITE_URL/"], | ||
"sitemap_urls": ["https://YOUR_WEBSITE_URL/sitemap.xml"], | ||
"selectors": { | ||
"lvl0": { | ||
"selector": ".vp-sidebar-heading.active", | ||
"global": true, | ||
"default_value": "Documentation" | ||
}, | ||
"lvl1": "[vp-content] h1", | ||
"lvl2": "[vp-content] h2", | ||
"lvl3": "[vp-content] h3", | ||
"lvl4": "[vp-content] h4", | ||
"lvl5": "[vp-content] h5", | ||
"lvl6": "[vp-content] h6", | ||
"content": "[vp-content] p, [vp-content] li", | ||
"lang": { | ||
"selector": "/html/@lang", | ||
"global": true, | ||
"type": "xpath" | ||
} | ||
}, | ||
"custom_settings": { | ||
"searchableAttributes": [ | ||
"hierarchy_radio_lvl0", | ||
"hierarchy_radio_lvl1", | ||
"hierarchy_radio_lvl2", | ||
"hierarchy_radio_lvl3", | ||
"hierarchy_radio_lvl4", | ||
"hierarchy_radio_lvl5", | ||
"hierarchy_lvl0", | ||
"hierarchy_lvl1", | ||
"hierarchy_lvl2", | ||
"hierarchy_lvl3", | ||
"hierarchy_lvl4", | ||
"hierarchy_lvl5", | ||
"hierarchy_lvl6", | ||
"content", | ||
"lang", | ||
"objectID", | ||
"page_rank", | ||
"level", | ||
"position" | ||
], | ||
"displayedAttributes": [ | ||
"hierarchy_radio_lvl0", | ||
"hierarchy_radio_lvl1", | ||
"hierarchy_radio_lvl2", | ||
"hierarchy_radio_lvl3", | ||
"hierarchy_radio_lvl4", | ||
"hierarchy_radio_lvl5", | ||
"hierarchy_lvl0", | ||
"hierarchy_lvl1", | ||
"hierarchy_lvl2", | ||
"hierarchy_lvl3", | ||
"hierarchy_lvl4", | ||
"hierarchy_lvl5", | ||
"hierarchy_lvl6", | ||
"anchor", | ||
"url", | ||
"lang", | ||
"content", | ||
"objectID" | ||
], | ||
"filterableAttributes": ["lang"] | ||
} | ||
} | ||
``` | ||
|
||
- `start_urls` and `sitemap_urls` (optional) shall be customized according to the website to be crawled. | ||
- `selectors` field can be customized according to third-party theme DOM structure. | ||
- You can add new fields to `custom_settings` according to your needs. | ||
|
||
::: important | ||
|
||
To let the plugin work: | ||
|
||
- `lang` selector must be kept as is in `selectors` filed | ||
- All fields that are currently in `custom_settings` must not be removed. | ||
|
||
::: | ||
|
||
Start scraping the document, `MEILISEARCH_HOST_URL` is the address of the host running MeiliSearch, `<MASTER_KEY>` is the master key, `<absolute-path-to-your-config-file>` is the absolute path to fetch the configuration file: | ||
|
||
```sh | ||
docker run -t --rm \ | ||
--network=host \ | ||
-e MEILISEARCH_HOST_URL='<MEILISEARCH_HOST_URL>' \ | ||
-e MEILISEARCH_API_KEY='<MASTER_KEY>' \ | ||
-v <absolute-path-to-your-config-file>:/docs-scraper/config.json \ | ||
getmeili/docs-scraper:latest pipenv run ./docs_scraper config.json | ||
``` | ||
|
||
When the crawl is complete, MeiliSearch stores the crawled document in the specified index. | ||
|
||
> See <https://www.meilisearch.com/docs/guides/front_end/search_bar_for_docs#scrape-your-content> | ||
|
||
## Get search index and api key | ||
|
||
To create an access key that only allows search operations, use the following request. The `indexes` array specifies which indexes this key can access, and `expiresAt` sets the key's expiration date. | ||
|
||
```sh | ||
curl \ | ||
-X POST 'http://localhost:7700/keys' \ | ||
-H 'Content-Type: application/json' \ | ||
-H 'Authorization: Bearer <MASTER_KEY>' \ | ||
--data-binary '{ | ||
"description": "Search records key", | ||
"actions": ["search"], | ||
"indexes": ["YOUR_INDEX_NAME"], | ||
"expiresAt": "2025-01-01T00:00:00Z" | ||
}' | ||
``` | ||
|
||
If successful, the response would look like this: | ||
|
||
```json | ||
{ | ||
"name": null, | ||
"description": "Search records key", | ||
"key": "adaf72e2a6d6f428ec465bc786ec41de868bbd53121997e89ba2299e9566c88213", | ||
"uid": "b84d1be5-caa5-4752-b078-8f40be39051d", | ||
"actions": ["search"], | ||
"indexes": ["YOUR_INDEX_NAME"], | ||
"expiresAt": "2025-01-01T00:00:00Z", | ||
"createdAt": "2024-01-27T06:50:33.668329328Z", | ||
"updatedAt": "2024-01-27T06:50:33.668329328Z" | ||
} | ||
``` | ||
|
||
This key can be exposed and used externally as needed. Enter it in your plugin options. | ||
|
||
```ts | ||
meilisearchPlugin({ | ||
host: 'YOUR_HOST', | ||
apiKey: 'adaf72e2a6d6f428ec465bc786ec41de868bbd53121997e89ba2299e9566c88213', | ||
indexUid: 'YOUR_INDEX_NAME', | ||
}) | ||
``` | ||
|
||
## Options | ||
|
||
### host | ||
|
||
- Type: `string` | ||
|
||
- Required: `true` | ||
|
||
- Details: | ||
|
||
Provide the HTTP address of the MeiliSearch API. | ||
|
||
### apiKey | ||
|
||
- Type: `string` | ||
|
||
- Required: `true` | ||
|
||
- Details: | ||
|
||
API key generated by MeiliSearch. | ||
|
||
### indexUid | ||
|
||
- Type: `string` | ||
|
||
- Required: `true` | ||
|
||
- Details: | ||
|
||
Specify the index name used for searching. | ||
|
||
### translations | ||
Mister-Hope marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
- Type: `DocSearchTranslations` | ||
|
||
- Details: | ||
|
||
Allows you to replace the default text in the DocSearch button and popup. | ||
|
||
### hotKeys | ||
|
||
- Type: `string[] | false` | ||
|
||
- Default: `['ctrl+k', 's', '/']` | ||
|
||
- Details: | ||
|
||
An array of hotkeys to trigger the search modal. When the value is `false`, the search modal cannot be triggered with any key. | ||
|
||
### debounceDuration | ||
|
||
- Type: `number | false` | ||
|
||
- Default: `200` | ||
|
||
- Details: | ||
|
||
The number of milliseconds that wait between keystrokes to determine whether a search should be performed,Setting the value here to `0` or `false` is logically equivalent. | ||
|
||
### searchParams | ||
|
||
- Type: `SearchParams` | ||
|
||
- Required: `false` | ||
|
||
- Details: | ||
|
||
Parameters of MeiliSearch API. | ||
|
||
- Also see: | ||
- [Meilisearch API docs](https://www.meilisearch.com/docs/reference/api/search#search-parameters) | ||
|
||
## Components | ||
|
||
- SearchBox |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.