@nikala-ui/folio-algolia 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -5
- package/dist/adapter.js +13 -0
- package/dist/browser.d.ts +1 -0
- package/dist/browser.js +1 -0
- package/dist/types.d.ts +5 -0
- package/package.json +6 -2
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ Folio.
|
|
|
10
10
|
|
|
11
11
|
## Requirements
|
|
12
12
|
|
|
13
|
-
- Folio `0.
|
|
13
|
+
- Folio `0.15.0` or newer;
|
|
14
14
|
- an Algolia index containing the same page URLs used by Folio;
|
|
15
15
|
- an Algolia Search-Only API key.
|
|
16
16
|
|
|
@@ -43,6 +43,10 @@ export default {
|
|
|
43
43
|
The adapter implements Folio's `SearchAdapter` contract. The configuration
|
|
44
44
|
contains no Algolia request logic and no indexing code.
|
|
45
45
|
|
|
46
|
+
The adapter also declares a browser runtime descriptor. Folio uses that
|
|
47
|
+
descriptor to load only the browser-safe adapter module; the consumer's full
|
|
48
|
+
`docs.config.ts` and server-only indexing code are not bundled into the site.
|
|
49
|
+
|
|
46
50
|
## Environment variables
|
|
47
51
|
|
|
48
52
|
Create a `.env` file in the documentation project:
|
|
@@ -163,10 +167,10 @@ Most Folio sites should use the exported `algoliaAdapter` instance instead.
|
|
|
163
167
|
|
|
164
168
|
## Migration from 0.1.x
|
|
165
169
|
|
|
166
|
-
Version `0.
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
configuration remains compatible:
|
|
170
|
+
Version `0.3.0` adds the browser runtime descriptor and requires Folio
|
|
171
|
+
`0.15.0` or newer. The server-only indexing entrypoint from `0.2.0` remains
|
|
172
|
+
available at `@nikala-ui/folio-algolia/indexing`. Existing browser-side
|
|
173
|
+
adapter configuration remains compatible:
|
|
170
174
|
|
|
171
175
|
```ts
|
|
172
176
|
import { algoliaAdapter } from "@nikala-ui/folio-algolia";
|
package/dist/adapter.js
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
import { getAlgoliaEnv } from "./env.js";
|
|
2
2
|
import { searchAlgolia } from "./client.js";
|
|
3
|
+
const BROWSER_RUNTIME_MODULE = "@nikala-ui/folio-algolia/browser";
|
|
4
|
+
function browserRuntime(options) {
|
|
5
|
+
return {
|
|
6
|
+
module: BROWSER_RUNTIME_MODULE,
|
|
7
|
+
exportName: "createAlgoliaAdapter",
|
|
8
|
+
options,
|
|
9
|
+
};
|
|
10
|
+
}
|
|
3
11
|
export function createAlgoliaAdapter(options) {
|
|
4
12
|
return {
|
|
5
13
|
name: "algolia",
|
|
14
|
+
runtime: browserRuntime(options),
|
|
6
15
|
async search({ query, pages }) {
|
|
7
16
|
const normalizedQuery = query.trim();
|
|
8
17
|
if (!normalizedQuery)
|
|
@@ -16,6 +25,10 @@ export function createAlgoliaAdapterFromEnv() {
|
|
|
16
25
|
}
|
|
17
26
|
export const algoliaAdapter = {
|
|
18
27
|
name: "algolia",
|
|
28
|
+
runtime: {
|
|
29
|
+
module: BROWSER_RUNTIME_MODULE,
|
|
30
|
+
exportName: "createAlgoliaAdapterFromEnv",
|
|
31
|
+
},
|
|
19
32
|
search(context) {
|
|
20
33
|
return createAlgoliaAdapterFromEnv().search(context);
|
|
21
34
|
},
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createAlgoliaAdapter, createAlgoliaAdapterFromEnv } from "./adapter.js";
|
package/dist/browser.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createAlgoliaAdapter, createAlgoliaAdapterFromEnv } from "./adapter.js";
|
package/dist/types.d.ts
CHANGED
|
@@ -22,5 +22,10 @@ export interface FolioSearchContext {
|
|
|
22
22
|
export interface FolioSearchAdapter {
|
|
23
23
|
name: string;
|
|
24
24
|
search: (context: FolioSearchContext) => PageData[] | Promise<PageData[]>;
|
|
25
|
+
runtime?: {
|
|
26
|
+
module: string;
|
|
27
|
+
exportName: string;
|
|
28
|
+
options?: unknown;
|
|
29
|
+
};
|
|
25
30
|
}
|
|
26
31
|
export type FolioPage = PageData;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nikala-ui/folio-algolia",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Algolia search adapter for Folio documentation sites",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -24,6 +24,10 @@
|
|
|
24
24
|
"./indexing": {
|
|
25
25
|
"types": "./dist/indexing/index.d.ts",
|
|
26
26
|
"import": "./dist/indexing/index.js"
|
|
27
|
+
},
|
|
28
|
+
"./browser": {
|
|
29
|
+
"types": "./dist/browser.d.ts",
|
|
30
|
+
"import": "./dist/browser.js"
|
|
27
31
|
}
|
|
28
32
|
},
|
|
29
33
|
"files": ["dist"],
|
|
@@ -35,7 +39,7 @@
|
|
|
35
39
|
"package:check": "bun run check && npm pack --dry-run"
|
|
36
40
|
},
|
|
37
41
|
"peerDependencies": {
|
|
38
|
-
"@nikala-ui/folio": ">=0.
|
|
42
|
+
"@nikala-ui/folio": ">=0.15.0"
|
|
39
43
|
},
|
|
40
44
|
"devDependencies": {
|
|
41
45
|
"@nikala-ui/folio": "^0.14.0",
|