@@ -163,86 +163,46 @@ If indexing fails (network error, bad credentials, etc.) the build **does not fa
163163
164164---
165165
166- ## Testing the plugin locally
166+ ## Testing Locally (Demo Site)
167+
168+ The repository includes a ready-to-use demo site in the ` demo-site/ ` folder. This is the best way to test changes to the plugin.
167169
168170### Step 1 — Build the plugin
169171
172+ First, build the plugin from the root directory to generate the ` dist ` folder.
173+
170174``` bash
171- cd vitepress-plugin-moss
172175pnpm install
173176pnpm build
174- # dist/ is now populated
175177```
176178
177- ### Step 2 — Create a minimal test VitePress site
178-
179- ``` bash
180- mkdir /tmp/test-docs && cd /tmp/test-docs
181- npm init -y
182- npm install vitepress
183- ```
179+ ### Step 2 — Set up the Demo Site
184180
185- Add ` "type": "module" ` to the generated ` package.json ` :
186-
187- ``` json
188- {
189- "name" : " test-docs" ,
190- "type" : " module" ,
191- ...
192- }
193- ```
194-
195- Create some pages:
181+ Navigate to the demo site directory and install its dependencies.
196182
197183``` bash
198- mkdir -p docs/.vitepress
199- echo " # Home\n\nThis is the home page." > docs/index.md
200- echo " # Guide\n\n## Installation\n\nRun npm install." > docs/guide.md
184+ cd demo-site
185+ npm install
201186```
202187
203- ### Step 3 — Link the local plugin
188+ ### Step 3 — Configure and Build
189+
190+ The demo site is already configured to use the local plugin. You just need to add your Moss credentials to ` demo-site/docs/.vitepress/config.ts ` (or use environment variables).
204191
205192``` bash
206- # From inside /tmp/test-docs
207- npm install /path/to/ vitepress-plugin-moss
193+ # From inside demo-site/
194+ npx vitepress build docs
208195```
209196
210- ### Step 4 — Configure VitePress
211-
212- ``` ts
213- // docs/.vitepress/config.ts
214- import { defineConfig } from ' vitepress'
215- import { mossIndexerPlugin } from ' vitepress-plugin-moss'
216-
217- export default defineConfig ({
218- title: ' Test Docs' ,
219- themeConfig: {
220- search: {
221- provider: ' moss' as any ,
222- options: {
223- projectId: process .env .MOSS_PROJECT_ID ! ,
224- projectKey: process .env .MOSS_PROJECT_KEY ! ,
225- indexName: ' test-docs' ,
226- },
227- },
228- },
229- async buildEnd(siteConfig ) {
230- const plugin = await mossIndexerPlugin (siteConfig )
231- if (typeof plugin .buildEnd === ' function' ) {
232- await (plugin .buildEnd as Function ).call ({ environment: { name: ' client' } })
233- }
234- },
235- })
236- ```
197+ ### Step 4 — Preview
237198
238- ### Step 5 — Run the build
199+ Start the preview server to test the search modal.
239200
240201``` bash
241- cd /tmp/test-docs
242- MOSS_PROJECT_ID=xxx MOSS_PROJECT_KEY=yyy npx vitepress build docs
202+ npx vitepress preview docs
243203```
244204
245- You should see the indexing output described in [ Build output ] ( #build-output ) above .
205+ Open [ http://localhost:4173 ] ( http://localhost:4173 ) in your browser and verify the search functionality .
246206
247207---
248208
0 commit comments