|
21 | 21 | <p align="center">⚡ Lightning Fast, Ultra Relevant, and Typo-Tolerant Search Engine MeiliSearch plugin for Vuepress</p> |
22 | 22 |
|
23 | 23 | **MeiliSearch Vuepress** is a **MeiliSearch** plugin for Vuepress. **MeiliSearch** is a powerful, fast, open-source, easy to use and deploy search engine. Both searching and indexing are highly customizable. Features such as typo-tolerance, filters, and synonyms are provided out-of-the-box. |
| 24 | + |
| 25 | +This plugin is used in production on the [MeiliSearch documentation](https://docs.meilisearch.com/). |
| 26 | + |
| 27 | +. |
| 28 | + |
| 29 | +## Table of Contents <!-- omit in toc --> |
| 30 | + |
| 31 | +- [Usage](#usage) |
| 32 | + - [Run MeiliSearch](#run-meilisearch) |
| 33 | + - [Basic usage](#basic-usage) |
| 34 | + - [Customization](#customization) |
| 35 | +- [Scrap your Content](#scrap-your-content) |
| 36 | + - [Your MeiliSearch Instance](#your-meilisearch-instance) |
| 37 | + - [Your Scraper](#your-scraper) |
| 38 | +- [Development Workflow](#development-workflow) |
| 39 | +- [Related Repositories](#related-repositories) |
| 40 | +- [🤖 Compatibility with MeiliSearch](#-compatibility-with-meilisearch) |
| 41 | + |
| 42 | +## Usage |
| 43 | + |
| 44 | +### Run MeiliSearch |
| 45 | + |
| 46 | +First of all, you need your Vuepress content to be scraped and pushed into a MeiliSearch instance. |
| 47 | + |
| 48 | +This can be done in few steps. Read the [dedicated section](#scrap-your-content). |
| 49 | + |
| 50 | +The host URL, the API key and the index UID you will provide in your configuration file are the credentials of this MeiliSearch instance. |
| 51 | + |
| 52 | +**Without running a MeiliSearch instance, the next steps will not work.** |
| 53 | + |
| 54 | +### Basic usage |
| 55 | + |
| 56 | +In your Vuepress project: |
| 57 | + |
| 58 | +```bash |
| 59 | +$ yarn add vuepress-plugin-meilisearch |
| 60 | +# or |
| 61 | +$ npm install vuepress-plugin-meilisearch |
| 62 | +``` |
| 63 | + |
| 64 | +In your `config.js` file: |
| 65 | + |
| 66 | +```js |
| 67 | +module.exports = { |
| 68 | + plugins: [ |
| 69 | + [ |
| 70 | + "vuepress-plugin-meilisearch", |
| 71 | + { |
| 72 | + "hostUrl": "https://mymeilisearch.com", |
| 73 | + "apiKey": "XXX", |
| 74 | + "indexUid": "docs" |
| 75 | + } |
| 76 | + ], |
| 77 | + ], |
| 78 | +} |
| 79 | +``` |
| 80 | + |
| 81 | +**WARNING**: Since the configuration file is public, we recommand to provide the MeiliSearch public key, which is enough to perform searches.<br> |
| 82 | +Read more about [MeiliSearch authentication](https://docs.meilisearch.com/guides/advanced_guides/authentication.html#authentication). |
| 83 | + |
| 84 | +### Customization |
| 85 | + |
| 86 | +```js |
| 87 | +module.exports = { |
| 88 | + plugins: [ |
| 89 | + [ |
| 90 | + "vuepress-plugin-meilisearch", |
| 91 | + { |
| 92 | + "hostUrl": "https://mymeilisearch.com", // Mandatory |
| 93 | + "apiKey": "XXX", // Mandatory |
| 94 | + "indexUid": "docs-test", // Mandatory |
| 95 | + "placeholder": "Search as you type...", // Default: "" |
| 96 | + "maxSuggestions": 10, // Default: 5 |
| 97 | + "hotKeys": [], // Default: ['s', '/'] |
| 98 | + "cropLength": 50 // Default: 30 |
| 99 | + } |
| 100 | + ], |
| 101 | + ], |
| 102 | +} |
| 103 | +``` |
| 104 | + |
| 105 | +## Scrap your Content |
| 106 | + |
| 107 | +To use this plugin, your need: |
| 108 | +- a MeiliSearch instance running in production. |
| 109 | +- a scraping tool that scraps your Vuepress pages on regular bases. |
| 110 | + |
| 111 | +### Your MeiliSearch Instance |
| 112 | + |
| 113 | +This step has to be done on your side: MeiliSearch is open-source and can run on your own server! 😄 |
| 114 | + |
| 115 | +Here is the [documentation to install and run MeiliSearch](https://docs.meilisearch.com/guides/advanced_guides/installation.html#installation). |
| 116 | + |
| 117 | +_A tutorial about how to run MeiliSearch in production is coming..._ |
| 118 | + |
| 119 | +### Your Scraper |
| 120 | + |
| 121 | +We already provide a scraper for your website: [docs-scraper](https://github.com/meilisearch/docs-scraper).<br> |
| 122 | +This scraper is used in production on the [MeiliSearch documentation](https://docs.meilisearch.com/). |
| 123 | + |
| 124 | +All the steps to use it are detailed in the scraper repository.<br> |
| 125 | +You can easily run the scraper with Docker or in a GitHub Action. The best would be to run the scraper on each website deployment. |
| 126 | + |
| 127 | +## Development Workflow |
| 128 | + |
| 129 | +### Install <!-- omit in toc --> |
| 130 | + |
| 131 | +```bash |
| 132 | +$ yarn install |
| 133 | +``` |
| 134 | + |
| 135 | +### Test with the Playground <!-- omit in toc --> |
| 136 | + |
| 137 | +A playground of a Vuepress environment is provided to test the plugin. |
| 138 | + |
| 139 | +```bash |
| 140 | +$ yarn serve |
| 141 | +``` |
| 142 | + |
| 143 | +Then, open your browser on the indicated URL and test the search bar 🙂 |
| 144 | + |
| 145 | +Since the automatic tests are not relevant, we really recommend to use it during development. |
| 146 | + |
| 147 | +### Tests and Linter <!-- omit in toc --> |
| 148 | + |
| 149 | +```bash |
| 150 | +# Automatic tests (need improvement) |
| 151 | +$ yarn test |
| 152 | +# Linter |
| 153 | +$ yarn lint |
| 154 | +# Linter with auto-correct |
| 155 | +$ yarn lint:fix |
| 156 | +``` |
| 157 | + |
| 158 | +### Release <!-- omit in toc --> |
| 159 | + |
| 160 | +MeiliSearch tools follow the [Semantic Versioning Convention](https://semver.org/). |
| 161 | + |
| 162 | +You must do a PR modifying the file `package.json` with the right version.<br> |
| 163 | + |
| 164 | +```javascript |
| 165 | +"version": X.X.X |
| 166 | +``` |
| 167 | + |
| 168 | +Once the changes are merged on `master`, in your terminal, you must be on the `master` branch and push a new tag with the right version: |
| 169 | + |
| 170 | +```bash |
| 171 | +$ git checkout master |
| 172 | +$ git pull origin master |
| 173 | +$ git tag vX.X.X |
| 174 | +$ git push --tag origin master |
| 175 | +``` |
| 176 | + |
| 177 | +A GitHub Action will be triggered and push the package on [npm](https://www.npmjs.com/package/vuepress-plugin-meilisearch). |
| 178 | + |
| 179 | +## Related Repositories |
| 180 | + |
| 181 | +- [docs-searchBar.js](https://github.com/meilisearch/docs-searchbar.js): the library used to display the dropdown of this plugin. It can be useful if you want a search bar for your documentation but you don't use vuepress. |
| 182 | +- [docs-scraper](https://github.com/meilisearch/docs-scraper): the scraper used to scrap websites pages and automatically index the content in MeiliSearch. |
| 183 | + |
| 184 | +## 🤖 Compatibility with MeiliSearch |
| 185 | + |
| 186 | +This plugin works for MeiliSearch `>=0.10`. |
0 commit comments