Lunr integration for Astro; client-side search for statically hosted pages.
0 | { | ||
1 | "name": "@siverv/astro-lunr", | ||
2 | - | "version": "0.0.2", | |
3 | + | "version": "0.0.3", | |
4 | "license" : "GPL-3.0", | ||
5 | "description": "Lunr integration for Astro", | ||
... | |||
26 | "rehype": "^12.0.1" | ||
27 | } |
0 | import fs from 'node:fs'; | ||
1 | import path from 'node:path'; | ||
... | |||
61 | viteServer.middlewares.use((req, res, next) => { | ||
62 | if(req.url.endsWith("/idx.json") || req.url.endsWith("/docs.json")){ | ||
63 | - | let path = req.url.slice(1); | |
64 | - | if(config.base && config.base != "./"){ | |
65 | - | let base = config.base.startsWith("./") ? config.base.slice(2) : config.base; | |
66 | - | path = path.replace(base, "./"); | |
67 | + | let path = req.url; | |
68 | + | if(config.base && path.startsWith(config.base)){ | |
69 | + | path = path.replace(config.base, ""); | |
70 | } | ||
71 | let preBuiltPath = new URL(path, config.outDir); | ||
... | |||
159 | } | ||
160 | } |
0 | |||
1 | |||
... | |||
33 | | `verbose` | boolean | Debug log | | ||
34 | |||
35 | - | If using `subDir` or the astro-config `base`, set the env-variable `PUBLIC_LUNR_DIR` to be `/base/subDir/` | |
36 | - | ||
37 | ### Example from astro-git-view | ||
38 | |||
... | |||
111 | To properly search files that are not usually genereated in the build-step, you would need to have a separate build-step that includes all pages that might be generated. | ||
112 |