fumadocs-core 15.5.0 → 15.5.2
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/dist/{algolia-RQ5VQJAB.js → algolia-NXNLN7TR.js} +1 -3
- package/dist/breadcrumb.js +0 -2
- package/dist/{chunk-XMCPKVJQ.js → chunk-3JSIVMCJ.js} +3 -4
- package/dist/{chunk-NNKVN7WA.js → chunk-5SU2O5AS.js} +1 -1
- package/dist/chunk-7GNSIKII.js +47 -0
- package/dist/{chunk-FVY6EZ3N.js → chunk-BBP7MIO4.js} +12 -14
- package/dist/content/index.js +0 -2
- package/dist/dynamic-link.js +2 -3
- package/dist/{fetch-W5EHIBOE.js → fetch-ZSD7GUCX.js} +2 -4
- package/dist/framework/index.d.ts +1 -1
- package/dist/framework/index.js +1 -2
- package/dist/framework/next.js +1 -2
- package/dist/framework/react-router.js +1 -2
- package/dist/framework/tanstack.js +1 -2
- package/dist/hide-if-empty.d.ts +14 -0
- package/dist/hide-if-empty.js +63 -0
- package/dist/highlight/client.js +0 -1
- package/dist/highlight/index.js +0 -1
- package/dist/i18n/index.d.ts +32 -2
- package/dist/i18n/index.js +0 -2
- package/dist/link.js +2 -3
- package/dist/mdx-plugins/index.js +1 -2
- package/dist/{orama-cloud-USLSOSXS.js → orama-cloud-I4WBDIAI.js} +2 -3
- package/dist/search/algolia.js +0 -2
- package/dist/search/client.d.ts +70 -7
- package/dist/search/client.js +20 -13
- package/dist/search/orama-cloud.js +0 -2
- package/dist/search/server.d.ts +2 -1
- package/dist/search/server.js +5 -2
- package/dist/server/index.d.ts +2 -1
- package/dist/server/index.js +0 -1
- package/dist/sidebar.js +0 -1
- package/dist/source/index.d.ts +96 -96
- package/dist/source/index.js +214 -224
- package/dist/static-QTPM5MZT.js +60 -0
- package/dist/toc.js +0 -1
- package/dist/utils/use-effect-event.js +0 -1
- package/dist/utils/use-media-query.js +0 -1
- package/dist/utils/use-on-change.js +0 -1
- package/package.json +21 -13
- package/dist/chunk-MLKGABMK.js +0 -9
- package/dist/config-Cm58P4fz.d.ts +0 -32
- package/dist/static-VESU2S64.js +0 -61
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import "./chunk-MLKGABMK.js";
|
|
2
|
-
|
|
3
1
|
// src/search/client/algolia.ts
|
|
4
2
|
function groupResults(hits) {
|
|
5
3
|
const grouped = [];
|
|
@@ -23,7 +21,7 @@ function groupResults(hits) {
|
|
|
23
21
|
}
|
|
24
22
|
return grouped;
|
|
25
23
|
}
|
|
26
|
-
async function searchDocs(query,
|
|
24
|
+
async function searchDocs(query, { indexName, onSearch, client, locale, tag }) {
|
|
27
25
|
if (query.length > 0) {
|
|
28
26
|
const result = onSearch ? await onSearch(query, tag, locale) : await client.searchForHits({
|
|
29
27
|
requests: [
|
package/dist/breadcrumb.js
CHANGED
|
@@ -5,17 +5,16 @@ function splitPath(path) {
|
|
|
5
5
|
function joinPath(...paths) {
|
|
6
6
|
const out = [];
|
|
7
7
|
const parsed = paths.flatMap(splitPath);
|
|
8
|
-
|
|
9
|
-
switch (
|
|
8
|
+
for (const seg of parsed) {
|
|
9
|
+
switch (seg) {
|
|
10
10
|
case "..":
|
|
11
11
|
out.pop();
|
|
12
12
|
break;
|
|
13
13
|
case ".":
|
|
14
14
|
break;
|
|
15
15
|
default:
|
|
16
|
-
out.push(
|
|
16
|
+
out.push(seg);
|
|
17
17
|
}
|
|
18
|
-
parsed.shift();
|
|
19
18
|
}
|
|
20
19
|
return out.join("/");
|
|
21
20
|
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// src/source/path.ts
|
|
2
|
+
function basename(path, ext) {
|
|
3
|
+
const idx = path.lastIndexOf("/");
|
|
4
|
+
return path.substring(
|
|
5
|
+
idx === -1 ? 0 : idx + 1,
|
|
6
|
+
ext ? path.length - ext.length : path.length
|
|
7
|
+
);
|
|
8
|
+
}
|
|
9
|
+
function extname(path) {
|
|
10
|
+
const dotIdx = path.lastIndexOf(".");
|
|
11
|
+
if (dotIdx !== -1) {
|
|
12
|
+
return path.substring(dotIdx);
|
|
13
|
+
}
|
|
14
|
+
return "";
|
|
15
|
+
}
|
|
16
|
+
function dirname(path) {
|
|
17
|
+
return path.split("/").slice(0, -1).join("/");
|
|
18
|
+
}
|
|
19
|
+
function parseFilePath(path) {
|
|
20
|
+
const ext = extname(path);
|
|
21
|
+
const name = basename(path, ext);
|
|
22
|
+
const dir = dirname(path);
|
|
23
|
+
return {
|
|
24
|
+
dirname: dir,
|
|
25
|
+
name,
|
|
26
|
+
ext,
|
|
27
|
+
path,
|
|
28
|
+
get flattenedPath() {
|
|
29
|
+
return [dir, name].filter((p) => p.length > 0).join("/");
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function parseFolderPath(path) {
|
|
34
|
+
return {
|
|
35
|
+
dirname: dirname(path),
|
|
36
|
+
name: basename(path),
|
|
37
|
+
path
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export {
|
|
42
|
+
basename,
|
|
43
|
+
extname,
|
|
44
|
+
dirname,
|
|
45
|
+
parseFilePath,
|
|
46
|
+
parseFolderPath
|
|
47
|
+
};
|
|
@@ -12,24 +12,22 @@ var FrameworkContext = createContext("FrameworkContext", {
|
|
|
12
12
|
usePathname: notImplemented
|
|
13
13
|
});
|
|
14
14
|
function FrameworkProvider({
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
Link: Link2,
|
|
16
|
+
useRouter: useRouter2,
|
|
17
|
+
useParams: useParams2,
|
|
18
|
+
usePathname: usePathname2,
|
|
19
|
+
Image: Image2,
|
|
20
|
+
children
|
|
17
21
|
}) {
|
|
18
22
|
const framework = React.useMemo(
|
|
19
23
|
() => ({
|
|
20
|
-
usePathname:
|
|
21
|
-
useRouter:
|
|
22
|
-
Link:
|
|
23
|
-
Image:
|
|
24
|
-
useParams:
|
|
24
|
+
usePathname: usePathname2,
|
|
25
|
+
useRouter: useRouter2,
|
|
26
|
+
Link: Link2,
|
|
27
|
+
Image: Image2,
|
|
28
|
+
useParams: useParams2
|
|
25
29
|
}),
|
|
26
|
-
[
|
|
27
|
-
props.Link,
|
|
28
|
-
props.usePathname,
|
|
29
|
-
props.useRouter,
|
|
30
|
-
props.useParams,
|
|
31
|
-
props.Image
|
|
32
|
-
]
|
|
30
|
+
[Link2, usePathname2, useRouter2, useParams2, Image2]
|
|
33
31
|
);
|
|
34
32
|
return /* @__PURE__ */ jsx(FrameworkContext.Provider, { value: framework, children });
|
|
35
33
|
}
|
package/dist/content/index.js
CHANGED
package/dist/dynamic-link.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
3
|
Link
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-5SU2O5AS.js";
|
|
5
5
|
import {
|
|
6
6
|
useParams
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import "./chunk-MLKGABMK.js";
|
|
7
|
+
} from "./chunk-BBP7MIO4.js";
|
|
9
8
|
|
|
10
9
|
// src/dynamic-link.tsx
|
|
11
10
|
import { forwardRef, useMemo } from "react";
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import "./chunk-MLKGABMK.js";
|
|
2
|
-
|
|
3
1
|
// src/search/client/fetch.ts
|
|
4
2
|
var cache = /* @__PURE__ */ new Map();
|
|
5
|
-
async function fetchDocs(query, locale, tag
|
|
3
|
+
async function fetchDocs(query, { api = "/api/search", locale, tag }) {
|
|
6
4
|
const params = new URLSearchParams();
|
|
7
5
|
params.set("query", query);
|
|
8
6
|
if (locale) params.set("locale", locale);
|
|
9
7
|
if (tag) params.set("tag", tag);
|
|
10
|
-
const key = `${
|
|
8
|
+
const key = `${api}?${params}`;
|
|
11
9
|
const cached = cache.get(key);
|
|
12
10
|
if (cached) return cached;
|
|
13
11
|
const res = await fetch(key);
|
|
@@ -29,7 +29,7 @@ interface Framework {
|
|
|
29
29
|
}>;
|
|
30
30
|
Image?: FC<ImageProps>;
|
|
31
31
|
}
|
|
32
|
-
declare function FrameworkProvider({ children,
|
|
32
|
+
declare function FrameworkProvider({ Link, useRouter, useParams, usePathname, Image, children, }: Framework & {
|
|
33
33
|
children: ReactNode;
|
|
34
34
|
}): react_jsx_runtime.JSX.Element;
|
|
35
35
|
declare function usePathname(): string;
|
package/dist/framework/index.js
CHANGED
package/dist/framework/next.js
CHANGED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The built-in CSS `:empty` selector cannot detect if the children is hidden, classes such as `md:hidden` causes it to fail.
|
|
6
|
+
* This component is an enhancement to `empty:hidden` to fix the issue described above.
|
|
7
|
+
*
|
|
8
|
+
* This can be expensive, please avoid this whenever possible.
|
|
9
|
+
*/
|
|
10
|
+
declare function HideIfEmpty({ children }: {
|
|
11
|
+
children: ReactNode;
|
|
12
|
+
}): react_jsx_runtime.JSX.Element;
|
|
13
|
+
|
|
14
|
+
export { HideIfEmpty };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/hide-if-empty.tsx
|
|
4
|
+
import React from "react";
|
|
5
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
var isEmpty = (node) => {
|
|
7
|
+
for (let i = 0; i < node.childNodes.length; i++) {
|
|
8
|
+
const child = node.childNodes.item(i);
|
|
9
|
+
if (child.nodeType === Node.TEXT_NODE || child.nodeType === Node.ELEMENT_NODE && window.getComputedStyle(child).display !== "none") {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return true;
|
|
14
|
+
};
|
|
15
|
+
function HideIfEmpty({ children }) {
|
|
16
|
+
const id = React.useId();
|
|
17
|
+
const [empty, setEmpty] = React.useState();
|
|
18
|
+
React.useEffect(() => {
|
|
19
|
+
const element = document.querySelector(
|
|
20
|
+
`[data-fdid="${id}"]`
|
|
21
|
+
);
|
|
22
|
+
if (!element) return;
|
|
23
|
+
const onUpdate = () => {
|
|
24
|
+
setEmpty(isEmpty(element));
|
|
25
|
+
};
|
|
26
|
+
const observer = new ResizeObserver(onUpdate);
|
|
27
|
+
observer.observe(element);
|
|
28
|
+
onUpdate();
|
|
29
|
+
return () => {
|
|
30
|
+
observer.disconnect();
|
|
31
|
+
};
|
|
32
|
+
}, [id]);
|
|
33
|
+
let child;
|
|
34
|
+
if (React.isValidElement(children)) {
|
|
35
|
+
child = React.cloneElement(children, {
|
|
36
|
+
...children.props,
|
|
37
|
+
"data-fdid": id,
|
|
38
|
+
"data-empty": empty,
|
|
39
|
+
suppressHydrationWarning: true
|
|
40
|
+
});
|
|
41
|
+
} else {
|
|
42
|
+
child = React.Children.count(children) > 1 ? React.Children.only(null) : null;
|
|
43
|
+
}
|
|
44
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
45
|
+
child,
|
|
46
|
+
empty === void 0 && /* @__PURE__ */ jsx(
|
|
47
|
+
"script",
|
|
48
|
+
{
|
|
49
|
+
suppressHydrationWarning: true,
|
|
50
|
+
dangerouslySetInnerHTML: {
|
|
51
|
+
__html: `{
|
|
52
|
+
const element = document.querySelector('[data-fdid="${id}"]')
|
|
53
|
+
if (element) {
|
|
54
|
+
element.setAttribute('data-empty', String((${isEmpty.toString()})(element)))
|
|
55
|
+
}}`
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
)
|
|
59
|
+
] });
|
|
60
|
+
}
|
|
61
|
+
export {
|
|
62
|
+
HideIfEmpty
|
|
63
|
+
};
|
package/dist/highlight/client.js
CHANGED
package/dist/highlight/index.js
CHANGED
package/dist/i18n/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { I as I18nConfig } from '../config-Cm58P4fz.js';
|
|
2
1
|
import { NextMiddleware } from 'next/dist/server/web/types';
|
|
3
2
|
|
|
4
3
|
interface MiddlewareOptions extends I18nConfig {
|
|
@@ -9,4 +8,35 @@ interface MiddlewareOptions extends I18nConfig {
|
|
|
9
8
|
}
|
|
10
9
|
declare function createI18nMiddleware({ languages, defaultLanguage, format, hideLocale, }: MiddlewareOptions): NextMiddleware;
|
|
11
10
|
|
|
12
|
-
|
|
11
|
+
interface I18nConfig {
|
|
12
|
+
/**
|
|
13
|
+
* Supported locale codes.
|
|
14
|
+
*
|
|
15
|
+
* A page tree will be built for each language.
|
|
16
|
+
*/
|
|
17
|
+
languages: string[];
|
|
18
|
+
/**
|
|
19
|
+
* Default locale if not specified
|
|
20
|
+
*/
|
|
21
|
+
defaultLanguage: string;
|
|
22
|
+
/**
|
|
23
|
+
* Don't show the locale prefix on URL.
|
|
24
|
+
*
|
|
25
|
+
* - `always`: Always hide the prefix
|
|
26
|
+
* - `default-locale`: Only hide the default locale
|
|
27
|
+
* - `never`: Never hide the prefix
|
|
28
|
+
*
|
|
29
|
+
* This API uses `NextResponse.rewrite`.
|
|
30
|
+
*
|
|
31
|
+
* @defaultValue 'never'
|
|
32
|
+
*/
|
|
33
|
+
hideLocale?: 'always' | 'default-locale' | 'never';
|
|
34
|
+
/**
|
|
35
|
+
* Used by `loader()`, specify the way to parse i18n file structure.
|
|
36
|
+
*
|
|
37
|
+
* @defaultValue 'dot'
|
|
38
|
+
*/
|
|
39
|
+
parser?: 'dot' | 'dir';
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export { type I18nConfig, createI18nMiddleware };
|
package/dist/i18n/index.js
CHANGED
package/dist/link.js
CHANGED
|
@@ -5,12 +5,11 @@ import {
|
|
|
5
5
|
import {
|
|
6
6
|
joinPath,
|
|
7
7
|
slash
|
|
8
|
-
} from "../chunk-
|
|
8
|
+
} from "../chunk-3JSIVMCJ.js";
|
|
9
9
|
import {
|
|
10
10
|
defaultThemes,
|
|
11
11
|
getHighlighter
|
|
12
12
|
} from "../chunk-KNWSJ4IF.js";
|
|
13
|
-
import "../chunk-MLKGABMK.js";
|
|
14
13
|
|
|
15
14
|
// src/mdx-plugins/index.ts
|
|
16
15
|
import {
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
removeUndefined
|
|
3
3
|
} from "./chunk-KAOEMCTI.js";
|
|
4
|
-
import "./chunk-MLKGABMK.js";
|
|
5
4
|
|
|
6
5
|
// src/search/client/orama-cloud.ts
|
|
7
|
-
async function searchDocs(query,
|
|
6
|
+
async function searchDocs(query, options) {
|
|
8
7
|
const list = [];
|
|
9
|
-
const { index = "default", client, params: extraParams = {} } = options;
|
|
8
|
+
const { index = "default", client, params: extraParams = {}, tag } = options;
|
|
10
9
|
if (index === "crawler") {
|
|
11
10
|
const result2 = await client.search({
|
|
12
11
|
...extraParams,
|
package/dist/search/algolia.js
CHANGED
package/dist/search/client.d.ts
CHANGED
|
@@ -12,21 +12,46 @@ import 'mdast-util-mdx-jsx';
|
|
|
12
12
|
interface FetchOptions {
|
|
13
13
|
/**
|
|
14
14
|
* API route for search endpoint
|
|
15
|
+
*
|
|
16
|
+
* @defaultValue '/api/search'
|
|
15
17
|
*/
|
|
16
18
|
api?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Filter results with specific tag.
|
|
21
|
+
*/
|
|
22
|
+
tag?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Filter by locale
|
|
25
|
+
*/
|
|
26
|
+
locale?: string;
|
|
17
27
|
}
|
|
18
28
|
|
|
19
29
|
interface StaticOptions {
|
|
20
30
|
/**
|
|
21
31
|
* Where to download exported search indexes (URL)
|
|
32
|
+
*
|
|
33
|
+
* @defaultValue '/api/search'
|
|
22
34
|
*/
|
|
23
35
|
from?: string;
|
|
24
36
|
initOrama?: (locale?: string) => AnyOrama | Promise<AnyOrama>;
|
|
37
|
+
/**
|
|
38
|
+
* Filter results with specific tag.
|
|
39
|
+
*/
|
|
40
|
+
tag?: string;
|
|
41
|
+
/**
|
|
42
|
+
* Filter by locale (unsupported at the moment)
|
|
43
|
+
*/
|
|
44
|
+
locale?: string;
|
|
25
45
|
}
|
|
26
46
|
|
|
27
47
|
interface AlgoliaOptions {
|
|
28
48
|
indexName: string;
|
|
29
49
|
client: LiteClient;
|
|
50
|
+
/**
|
|
51
|
+
* Filter results with specific tag.
|
|
52
|
+
*/
|
|
53
|
+
tag?: string;
|
|
54
|
+
locale?: string;
|
|
30
55
|
onSearch?: (query: string, tag?: string, locale?: string) => Promise<{
|
|
31
56
|
results: SearchResponse<BaseIndex>[];
|
|
32
57
|
}>;
|
|
@@ -41,6 +66,14 @@ interface OramaCloudOptions {
|
|
|
41
66
|
*/
|
|
42
67
|
index?: 'default' | 'crawler';
|
|
43
68
|
params?: ClientSearchParams;
|
|
69
|
+
/**
|
|
70
|
+
* Filter results with specific tag.
|
|
71
|
+
*/
|
|
72
|
+
tag?: string;
|
|
73
|
+
/**
|
|
74
|
+
* Filter by locale (unsupported at the moment)
|
|
75
|
+
*/
|
|
76
|
+
locale?: string;
|
|
44
77
|
}
|
|
45
78
|
|
|
46
79
|
interface UseDocsSearch {
|
|
@@ -62,13 +95,43 @@ type Client = ({
|
|
|
62
95
|
type: 'orama-cloud';
|
|
63
96
|
} & OramaCloudOptions);
|
|
64
97
|
/**
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
98
|
+
* Provide a hook to query different official search clients.
|
|
99
|
+
*
|
|
100
|
+
* Note: it will re-query when its parameters changed, make sure to use `useCallback()` on functions passed to this hook.
|
|
101
|
+
*/
|
|
102
|
+
declare function useDocsSearch(clientOptions: Client & {
|
|
103
|
+
/**
|
|
104
|
+
* The debounced delay for performing a search (in ms).
|
|
105
|
+
* .
|
|
106
|
+
* @defaultValue 100
|
|
107
|
+
*/
|
|
108
|
+
delayMs?: number;
|
|
109
|
+
/**
|
|
110
|
+
* still perform search even if query is empty.
|
|
111
|
+
*
|
|
112
|
+
* @defaultValue false
|
|
113
|
+
*/
|
|
114
|
+
allowEmpty?: boolean;
|
|
115
|
+
},
|
|
116
|
+
/**
|
|
117
|
+
* @deprecated pass to `client` object instead
|
|
118
|
+
*/
|
|
119
|
+
_locale?: string,
|
|
120
|
+
/**
|
|
121
|
+
* @deprecated pass to `client` object instead
|
|
122
|
+
*/
|
|
123
|
+
_tag?: string,
|
|
124
|
+
/**
|
|
125
|
+
* @deprecated pass to `client` object instead
|
|
126
|
+
*/
|
|
127
|
+
_delayMs?: number,
|
|
128
|
+
/**
|
|
129
|
+
* @deprecated pass to `client` object instead
|
|
130
|
+
*/
|
|
131
|
+
_allowEmpty?: boolean,
|
|
132
|
+
/**
|
|
133
|
+
* @deprecated No longer used
|
|
71
134
|
*/
|
|
72
|
-
|
|
135
|
+
_key?: string): UseDocsSearch;
|
|
73
136
|
|
|
74
137
|
export { type AlgoliaOptions, type Client, type FetchOptions, type OramaCloudOptions, type StaticOptions, useDocsSearch };
|
package/dist/search/client.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useOnChange
|
|
3
3
|
} from "../chunk-EMWGTXSW.js";
|
|
4
|
-
import "../chunk-MLKGABMK.js";
|
|
5
4
|
|
|
6
5
|
// src/search/client.ts
|
|
7
6
|
import { useRef as useRef2, useState as useState2 } from "react";
|
|
@@ -23,7 +22,6 @@ function useDebounce(value, delayMs = 1e3) {
|
|
|
23
22
|
}
|
|
24
23
|
|
|
25
24
|
// src/search/client.ts
|
|
26
|
-
var staticClient;
|
|
27
25
|
function isDifferentDeep(a, b) {
|
|
28
26
|
if (Array.isArray(a) && Array.isArray(b)) {
|
|
29
27
|
return b.length !== a.length || a.some((v, i) => isDifferentDeep(v, b[i]));
|
|
@@ -37,7 +35,14 @@ function isDifferentDeep(a, b) {
|
|
|
37
35
|
}
|
|
38
36
|
return a !== b;
|
|
39
37
|
}
|
|
40
|
-
function useDocsSearch(
|
|
38
|
+
function useDocsSearch(clientOptions, _locale, _tag, _delayMs = 100, _allowEmpty = false, _key) {
|
|
39
|
+
const {
|
|
40
|
+
delayMs = _delayMs ?? 100,
|
|
41
|
+
allowEmpty = _allowEmpty ?? false,
|
|
42
|
+
...client
|
|
43
|
+
} = clientOptions;
|
|
44
|
+
client.tag ??= _tag;
|
|
45
|
+
client.locale ??= _locale;
|
|
41
46
|
const [search, setSearch] = useState2("");
|
|
42
47
|
const [results, setResults] = useState2("empty");
|
|
43
48
|
const [error, setError] = useState2();
|
|
@@ -45,7 +50,7 @@ function useDocsSearch(client, locale, tag, delayMs = 100, allowEmpty = false, k
|
|
|
45
50
|
const debouncedValue = useDebounce(search, delayMs);
|
|
46
51
|
const onStart = useRef2(void 0);
|
|
47
52
|
useOnChange(
|
|
48
|
-
|
|
53
|
+
[client, debouncedValue],
|
|
49
54
|
() => {
|
|
50
55
|
if (onStart.current) {
|
|
51
56
|
onStart.current();
|
|
@@ -59,20 +64,22 @@ function useDocsSearch(client, locale, tag, delayMs = 100, allowEmpty = false, k
|
|
|
59
64
|
async function run() {
|
|
60
65
|
if (debouncedValue.length === 0 && !allowEmpty) return "empty";
|
|
61
66
|
if (client.type === "fetch") {
|
|
62
|
-
const { fetchDocs } = await import("../fetch-
|
|
63
|
-
return fetchDocs(debouncedValue,
|
|
67
|
+
const { fetchDocs } = await import("../fetch-ZSD7GUCX.js");
|
|
68
|
+
return fetchDocs(debouncedValue, client);
|
|
64
69
|
}
|
|
65
70
|
if (client.type === "algolia") {
|
|
66
|
-
const { searchDocs } = await import("../algolia-
|
|
67
|
-
return searchDocs(debouncedValue,
|
|
71
|
+
const { searchDocs } = await import("../algolia-NXNLN7TR.js");
|
|
72
|
+
return searchDocs(debouncedValue, client);
|
|
68
73
|
}
|
|
69
74
|
if (client.type === "orama-cloud") {
|
|
70
|
-
const { searchDocs } = await import("../orama-cloud-
|
|
71
|
-
return searchDocs(debouncedValue,
|
|
75
|
+
const { searchDocs } = await import("../orama-cloud-I4WBDIAI.js");
|
|
76
|
+
return searchDocs(debouncedValue, client);
|
|
72
77
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
78
|
+
if (client.type === "static") {
|
|
79
|
+
const { search: search2 } = await import("../static-QTPM5MZT.js");
|
|
80
|
+
return search2(debouncedValue, client);
|
|
81
|
+
}
|
|
82
|
+
throw new Error("unknown search client");
|
|
76
83
|
}
|
|
77
84
|
void run().then((res) => {
|
|
78
85
|
if (interrupt) return;
|
package/dist/search/server.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { TypedDocument, Orama, Language, RawData, create, SearchParams } from '@orama/orama';
|
|
2
2
|
import { S as StructuredData } from '../remark-structure-DVje0Sib.js';
|
|
3
3
|
import { S as SortedResult } from '../types-Ch8gnVgO.js';
|
|
4
|
-
import {
|
|
4
|
+
import { I18nConfig } from '../i18n/index.js';
|
|
5
5
|
import { LoaderOutput, LoaderConfig, InferPageType } from '../source/index.js';
|
|
6
6
|
import 'mdast';
|
|
7
7
|
import 'unified';
|
|
8
8
|
import 'mdast-util-mdx-jsx';
|
|
9
|
+
import 'next/dist/server/web/types';
|
|
9
10
|
import 'react';
|
|
10
11
|
import '../page-tree-bSt6K__E.js';
|
|
11
12
|
|
package/dist/search/server.js
CHANGED
|
@@ -3,7 +3,10 @@ import {
|
|
|
3
3
|
searchSimple
|
|
4
4
|
} from "../chunk-WFUH5VBX.js";
|
|
5
5
|
import "../chunk-KAOEMCTI.js";
|
|
6
|
-
import
|
|
6
|
+
import {
|
|
7
|
+
basename,
|
|
8
|
+
extname
|
|
9
|
+
} from "../chunk-7GNSIKII.js";
|
|
7
10
|
|
|
8
11
|
// src/search/server.ts
|
|
9
12
|
import {
|
|
@@ -150,7 +153,7 @@ function pageToIndex(page) {
|
|
|
150
153
|
}
|
|
151
154
|
const structuredData = page.data.structuredData;
|
|
152
155
|
return {
|
|
153
|
-
title: page.data.title ?? page.
|
|
156
|
+
title: page.data.title ?? basename(page.path, extname(page.path)),
|
|
154
157
|
description: "description" in page.data ? page.data.description : void 0,
|
|
155
158
|
url: page.url,
|
|
156
159
|
id: page.url,
|
package/dist/server/index.d.ts
CHANGED
|
@@ -8,7 +8,8 @@ import { LoaderOutput, LoaderConfig, InferPageType } from '../source/index.js';
|
|
|
8
8
|
import 'react';
|
|
9
9
|
import 'unified';
|
|
10
10
|
import 'vfile';
|
|
11
|
-
import '../
|
|
11
|
+
import '../i18n/index.js';
|
|
12
|
+
import 'next/dist/server/web/types';
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* Flatten tree to an array of page nodes
|