@hanzo/docs-core 16.2.5
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/LICENSE +21 -0
- package/README.md +5 -0
- package/dist/algolia-IZEDLPHE.js +58 -0
- package/dist/breadcrumb.d.ts +46 -0
- package/dist/breadcrumb.js +81 -0
- package/dist/chunk-5PMI7QDD.js +220 -0
- package/dist/chunk-ADBHPKXG.js +78 -0
- package/dist/chunk-APKPSBSB.js +74 -0
- package/dist/chunk-CH7YHH7V.js +222 -0
- package/dist/chunk-EFVXL2PP.js +144 -0
- package/dist/chunk-EMWGTXSW.js +19 -0
- package/dist/chunk-FAEPKD7U.js +20 -0
- package/dist/chunk-FUUVPEA5.js +29 -0
- package/dist/chunk-GINBKBVQ.js +12 -0
- package/dist/chunk-GLRQBLGN.js +59 -0
- package/dist/chunk-JUF4WZ6G.js +117 -0
- package/dist/chunk-K4WNLOVQ.js +75 -0
- package/dist/chunk-L4JKQWCM.js +131 -0
- package/dist/chunk-MA6O2UUE.js +50 -0
- package/dist/chunk-ONG4RVCR.js +8 -0
- package/dist/chunk-OTD7MV33.js +53 -0
- package/dist/chunk-PFNP6PEB.js +11 -0
- package/dist/chunk-QJRXMG4S.js +275 -0
- package/dist/chunk-SH7BNTG7.js +38 -0
- package/dist/chunk-TWIDBWFG.js +84 -0
- package/dist/chunk-U67V476Y.js +35 -0
- package/dist/chunk-VLSDGCJE.js +47 -0
- package/dist/chunk-W6WTLKRA.js +73 -0
- package/dist/chunk-X2HFD5QJ.js +275 -0
- package/dist/chunk-XJ6ZQNEX.js +91 -0
- package/dist/chunk-XN2LKXFZ.js +101 -0
- package/dist/chunk-XOFXGHS4.js +93 -0
- package/dist/chunk-XZSI7AHE.js +67 -0
- package/dist/chunk-YVVDKJ2H.js +34 -0
- package/dist/chunk-ZMWYLUDP.js +21 -0
- package/dist/content/github.d.ts +40 -0
- package/dist/content/github.js +44 -0
- package/dist/content/index.d.ts +16 -0
- package/dist/content/index.js +30 -0
- package/dist/content/mdx/preset-bundler.d.ts +31 -0
- package/dist/content/mdx/preset-bundler.js +72 -0
- package/dist/content/mdx/preset-runtime.d.ts +31 -0
- package/dist/content/mdx/preset-runtime.js +71 -0
- package/dist/content/toc.d.ts +21 -0
- package/dist/content/toc.js +22 -0
- package/dist/definitions-pJ7PybYY.d.ts +60 -0
- package/dist/dynamic-link.d.ts +12 -0
- package/dist/dynamic-link.js +32 -0
- package/dist/fetch-IBTWQCJR.js +22 -0
- package/dist/framework/index.d.ts +41 -0
- package/dist/framework/index.js +18 -0
- package/dist/framework/next.d.ts +12 -0
- package/dist/framework/next.js +31 -0
- package/dist/framework/react-router.d.ts +12 -0
- package/dist/framework/react-router.js +59 -0
- package/dist/framework/tanstack.d.ts +15 -0
- package/dist/framework/tanstack.js +72 -0
- package/dist/framework/waku.d.ts +12 -0
- package/dist/framework/waku.js +63 -0
- package/dist/highlight/client.d.ts +15 -0
- package/dist/highlight/client.js +18 -0
- package/dist/highlight/index.d.ts +30 -0
- package/dist/highlight/index.js +13 -0
- package/dist/i18n/index.d.ts +39 -0
- package/dist/i18n/index.js +9 -0
- package/dist/i18n/middleware.d.ts +34 -0
- package/dist/i18n/middleware.js +76 -0
- package/dist/link.d.ts +18 -0
- package/dist/link.js +9 -0
- package/dist/loader-BvlPPJX0.d.ts +321 -0
- package/dist/mdx-plugins/codeblock-utils.d.ts +29 -0
- package/dist/mdx-plugins/codeblock-utils.js +9 -0
- package/dist/mdx-plugins/index.d.ts +20 -0
- package/dist/mdx-plugins/index.js +73 -0
- package/dist/mdx-plugins/rehype-code.d.ts +55 -0
- package/dist/mdx-plugins/rehype-code.js +15 -0
- package/dist/mdx-plugins/rehype-toc.d.ts +14 -0
- package/dist/mdx-plugins/rehype-toc.js +7 -0
- package/dist/mdx-plugins/remark-admonition.d.ts +20 -0
- package/dist/mdx-plugins/remark-admonition.js +8 -0
- package/dist/mdx-plugins/remark-code-tab.d.ts +30 -0
- package/dist/mdx-plugins/remark-code-tab.js +8 -0
- package/dist/mdx-plugins/remark-directive-admonition.d.ts +27 -0
- package/dist/mdx-plugins/remark-directive-admonition.js +7 -0
- package/dist/mdx-plugins/remark-gfm.d.ts +1 -0
- package/dist/mdx-plugins/remark-gfm.js +7 -0
- package/dist/mdx-plugins/remark-heading.d.ts +31 -0
- package/dist/mdx-plugins/remark-heading.js +8 -0
- package/dist/mdx-plugins/remark-image.d.ts +57 -0
- package/dist/mdx-plugins/remark-image.js +7 -0
- package/dist/mdx-plugins/remark-mdx-files.d.ts +40 -0
- package/dist/mdx-plugins/remark-mdx-files.js +7 -0
- package/dist/mdx-plugins/remark-mdx-mermaid.d.ts +15 -0
- package/dist/mdx-plugins/remark-mdx-mermaid.js +7 -0
- package/dist/mdx-plugins/remark-npm.d.ts +31 -0
- package/dist/mdx-plugins/remark-npm.js +8 -0
- package/dist/mdx-plugins/remark-steps.d.ts +23 -0
- package/dist/mdx-plugins/remark-steps.js +7 -0
- package/dist/mdx-plugins/remark-structure.d.ts +71 -0
- package/dist/mdx-plugins/remark-structure.js +12 -0
- package/dist/mixedbread-RAHDVXGJ.js +118 -0
- package/dist/negotiation/index.d.ts +19 -0
- package/dist/negotiation/index.js +11 -0
- package/dist/orama-cloud-UZAPMPFV.js +93 -0
- package/dist/page-tree/index.d.ts +33 -0
- package/dist/page-tree/index.js +17 -0
- package/dist/search/algolia.d.ts +69 -0
- package/dist/search/algolia.js +71 -0
- package/dist/search/client.d.ts +140 -0
- package/dist/search/client.js +99 -0
- package/dist/search/index.d.ts +26 -0
- package/dist/search/index.js +7 -0
- package/dist/search/orama-cloud.d.ts +79 -0
- package/dist/search/orama-cloud.js +60 -0
- package/dist/search/server.d.ts +136 -0
- package/dist/search/server.js +400 -0
- package/dist/source/client/index.d.ts +16 -0
- package/dist/source/client/index.js +41 -0
- package/dist/source/index.d.ts +42 -0
- package/dist/source/index.js +776 -0
- package/dist/source/plugins/lucide-icons.d.ts +14 -0
- package/dist/source/plugins/lucide-icons.js +23 -0
- package/dist/source/schema.d.ts +26 -0
- package/dist/source/schema.js +25 -0
- package/dist/static-A2YJ5TXV.js +62 -0
- package/dist/toc.d.ts +43 -0
- package/dist/toc.js +151 -0
- package/dist/util-bZU2QeJ2.d.ts +6 -0
- package/dist/utils/use-effect-event.d.ts +9 -0
- package/dist/utils/use-effect-event.js +16 -0
- package/dist/utils/use-media-query.d.ts +3 -0
- package/dist/utils/use-media-query.js +23 -0
- package/dist/utils/use-on-change.d.ts +8 -0
- package/dist/utils/use-on-change.js +7 -0
- package/package.json +222 -0
|
@@ -0,0 +1,400 @@
|
|
|
1
|
+
import {
|
|
2
|
+
searchAdvanced,
|
|
3
|
+
searchSimple
|
|
4
|
+
} from "../chunk-XOFXGHS4.js";
|
|
5
|
+
import "../chunk-ZMWYLUDP.js";
|
|
6
|
+
import {
|
|
7
|
+
basename,
|
|
8
|
+
extname
|
|
9
|
+
} from "../chunk-XZSI7AHE.js";
|
|
10
|
+
import {
|
|
11
|
+
createContentHighlighter
|
|
12
|
+
} from "../chunk-OTD7MV33.js";
|
|
13
|
+
import {
|
|
14
|
+
findPath
|
|
15
|
+
} from "../chunk-L4JKQWCM.js";
|
|
16
|
+
import "../chunk-U67V476Y.js";
|
|
17
|
+
|
|
18
|
+
// src/search/server.ts
|
|
19
|
+
import {
|
|
20
|
+
save
|
|
21
|
+
} from "@orama/orama";
|
|
22
|
+
|
|
23
|
+
// src/search/orama/create-endpoint.ts
|
|
24
|
+
function createEndpoint(server) {
|
|
25
|
+
const { search } = server;
|
|
26
|
+
return {
|
|
27
|
+
...server,
|
|
28
|
+
async staticGET() {
|
|
29
|
+
return Response.json(await server.export());
|
|
30
|
+
},
|
|
31
|
+
async GET(request) {
|
|
32
|
+
const url = new URL(request.url);
|
|
33
|
+
const query = url.searchParams.get("query");
|
|
34
|
+
if (!query) return Response.json([]);
|
|
35
|
+
return Response.json(
|
|
36
|
+
await search(query, {
|
|
37
|
+
tag: url.searchParams.get("tag")?.split(",") ?? void 0,
|
|
38
|
+
locale: url.searchParams.get("locale") ?? void 0,
|
|
39
|
+
mode: url.searchParams.get("mode") === "vector" ? "vector" : "full"
|
|
40
|
+
})
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// src/search/orama/create-db.ts
|
|
47
|
+
import {
|
|
48
|
+
create,
|
|
49
|
+
insertMultiple
|
|
50
|
+
} from "@orama/orama";
|
|
51
|
+
var simpleSchema = {
|
|
52
|
+
url: "string",
|
|
53
|
+
title: "string",
|
|
54
|
+
breadcrumbs: "string[]",
|
|
55
|
+
description: "string",
|
|
56
|
+
content: "string",
|
|
57
|
+
keywords: "string"
|
|
58
|
+
};
|
|
59
|
+
var advancedSchema = {
|
|
60
|
+
content: "string",
|
|
61
|
+
page_id: "string",
|
|
62
|
+
type: "string",
|
|
63
|
+
breadcrumbs: "string[]",
|
|
64
|
+
tags: "enum[]",
|
|
65
|
+
url: "string",
|
|
66
|
+
embeddings: "vector[512]"
|
|
67
|
+
};
|
|
68
|
+
async function createDB({
|
|
69
|
+
indexes,
|
|
70
|
+
tokenizer,
|
|
71
|
+
search: _,
|
|
72
|
+
...rest
|
|
73
|
+
}) {
|
|
74
|
+
const items = typeof indexes === "function" ? await indexes() : indexes;
|
|
75
|
+
const db = create({
|
|
76
|
+
schema: advancedSchema,
|
|
77
|
+
...rest,
|
|
78
|
+
components: {
|
|
79
|
+
...rest.components,
|
|
80
|
+
tokenizer: tokenizer ?? rest.components?.tokenizer
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
const mapTo = [];
|
|
84
|
+
items.forEach((page) => {
|
|
85
|
+
const pageTag = page.tag ?? [];
|
|
86
|
+
const tags = Array.isArray(pageTag) ? pageTag : [pageTag];
|
|
87
|
+
const data = page.structuredData;
|
|
88
|
+
let id = 0;
|
|
89
|
+
mapTo.push({
|
|
90
|
+
id: page.id,
|
|
91
|
+
page_id: page.id,
|
|
92
|
+
type: "page",
|
|
93
|
+
content: page.title,
|
|
94
|
+
breadcrumbs: page.breadcrumbs,
|
|
95
|
+
tags,
|
|
96
|
+
url: page.url
|
|
97
|
+
});
|
|
98
|
+
const nextId = () => `${page.id}-${id++}`;
|
|
99
|
+
if (page.description) {
|
|
100
|
+
mapTo.push({
|
|
101
|
+
id: nextId(),
|
|
102
|
+
page_id: page.id,
|
|
103
|
+
tags,
|
|
104
|
+
type: "text",
|
|
105
|
+
url: page.url,
|
|
106
|
+
content: page.description
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
for (const heading of data.headings) {
|
|
110
|
+
mapTo.push({
|
|
111
|
+
id: nextId(),
|
|
112
|
+
page_id: page.id,
|
|
113
|
+
type: "heading",
|
|
114
|
+
tags,
|
|
115
|
+
url: `${page.url}#${heading.id}`,
|
|
116
|
+
content: heading.content
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
for (const content of data.contents) {
|
|
120
|
+
mapTo.push({
|
|
121
|
+
id: nextId(),
|
|
122
|
+
page_id: page.id,
|
|
123
|
+
tags,
|
|
124
|
+
type: "text",
|
|
125
|
+
url: content.heading ? `${page.url}#${content.heading}` : page.url,
|
|
126
|
+
content: content.content
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
await insertMultiple(db, mapTo);
|
|
131
|
+
return db;
|
|
132
|
+
}
|
|
133
|
+
async function createDBSimple({
|
|
134
|
+
indexes,
|
|
135
|
+
tokenizer,
|
|
136
|
+
...rest
|
|
137
|
+
}) {
|
|
138
|
+
const items = typeof indexes === "function" ? await indexes() : indexes;
|
|
139
|
+
const db = create({
|
|
140
|
+
schema: simpleSchema,
|
|
141
|
+
...rest,
|
|
142
|
+
components: {
|
|
143
|
+
...rest.components,
|
|
144
|
+
tokenizer: tokenizer ?? rest.components?.tokenizer
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
await insertMultiple(
|
|
148
|
+
db,
|
|
149
|
+
items.map((page) => ({
|
|
150
|
+
title: page.title,
|
|
151
|
+
description: page.description,
|
|
152
|
+
breadcrumbs: page.breadcrumbs,
|
|
153
|
+
url: page.url,
|
|
154
|
+
content: page.content,
|
|
155
|
+
keywords: page.keywords
|
|
156
|
+
}))
|
|
157
|
+
);
|
|
158
|
+
return db;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// src/search/orama/create-from-source.ts
|
|
162
|
+
function defaultBuildIndex(source) {
|
|
163
|
+
function isBreadcrumbItem(item) {
|
|
164
|
+
return typeof item === "string" && item.length > 0;
|
|
165
|
+
}
|
|
166
|
+
return async (page) => {
|
|
167
|
+
let breadcrumbs;
|
|
168
|
+
let structuredData;
|
|
169
|
+
if ("structuredData" in page.data) {
|
|
170
|
+
structuredData = page.data.structuredData;
|
|
171
|
+
} else if ("load" in page.data && typeof page.data.load === "function") {
|
|
172
|
+
structuredData = (await page.data.load()).structuredData;
|
|
173
|
+
}
|
|
174
|
+
if (!structuredData)
|
|
175
|
+
throw new Error(
|
|
176
|
+
"Cannot find structured data from page, please define the page to index function."
|
|
177
|
+
);
|
|
178
|
+
const pageTree = source.getPageTree(page.locale);
|
|
179
|
+
const path = findPath(
|
|
180
|
+
pageTree.children,
|
|
181
|
+
(node) => node.type === "page" && node.url === page.url
|
|
182
|
+
);
|
|
183
|
+
if (path) {
|
|
184
|
+
breadcrumbs = [];
|
|
185
|
+
path.pop();
|
|
186
|
+
if (isBreadcrumbItem(pageTree.name)) {
|
|
187
|
+
breadcrumbs.push(pageTree.name);
|
|
188
|
+
}
|
|
189
|
+
for (const segment of path) {
|
|
190
|
+
if (!isBreadcrumbItem(segment.name)) continue;
|
|
191
|
+
breadcrumbs.push(segment.name);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
return {
|
|
195
|
+
title: page.data.title ?? basename(page.path, extname(page.path)),
|
|
196
|
+
breadcrumbs,
|
|
197
|
+
description: page.data.description,
|
|
198
|
+
url: page.url,
|
|
199
|
+
id: page.url,
|
|
200
|
+
structuredData
|
|
201
|
+
};
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
function createFromSource(source, options = {}) {
|
|
205
|
+
const { buildIndex = defaultBuildIndex(source) } = options;
|
|
206
|
+
if (source._i18n) {
|
|
207
|
+
return createI18nSearchAPI("advanced", {
|
|
208
|
+
...options,
|
|
209
|
+
i18n: source._i18n,
|
|
210
|
+
indexes: async () => {
|
|
211
|
+
const indexes = source.getLanguages().flatMap((entry) => {
|
|
212
|
+
return entry.pages.map(async (page) => ({
|
|
213
|
+
...await buildIndex(page),
|
|
214
|
+
locale: entry.language
|
|
215
|
+
}));
|
|
216
|
+
});
|
|
217
|
+
return Promise.all(indexes);
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
return createSearchAPI("advanced", {
|
|
222
|
+
...options,
|
|
223
|
+
indexes: async () => {
|
|
224
|
+
const indexes = source.getPages().map((page) => buildIndex(page));
|
|
225
|
+
return Promise.all(indexes);
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// src/search/orama/_stemmers.ts
|
|
231
|
+
var STEMMERS = {
|
|
232
|
+
arabic: "ar",
|
|
233
|
+
armenian: "am",
|
|
234
|
+
bulgarian: "bg",
|
|
235
|
+
czech: "cz",
|
|
236
|
+
danish: "dk",
|
|
237
|
+
dutch: "nl",
|
|
238
|
+
english: "en",
|
|
239
|
+
finnish: "fi",
|
|
240
|
+
french: "fr",
|
|
241
|
+
german: "de",
|
|
242
|
+
greek: "gr",
|
|
243
|
+
hungarian: "hu",
|
|
244
|
+
indian: "in",
|
|
245
|
+
indonesian: "id",
|
|
246
|
+
irish: "ie",
|
|
247
|
+
italian: "it",
|
|
248
|
+
lithuanian: "lt",
|
|
249
|
+
nepali: "np",
|
|
250
|
+
norwegian: "no",
|
|
251
|
+
portuguese: "pt",
|
|
252
|
+
romanian: "ro",
|
|
253
|
+
russian: "ru",
|
|
254
|
+
serbian: "rs",
|
|
255
|
+
slovenian: "ru",
|
|
256
|
+
spanish: "es",
|
|
257
|
+
swedish: "se",
|
|
258
|
+
tamil: "ta",
|
|
259
|
+
turkish: "tr",
|
|
260
|
+
ukrainian: "uk",
|
|
261
|
+
sanskrit: "sk"
|
|
262
|
+
};
|
|
263
|
+
|
|
264
|
+
// src/search/orama/create-i18n.ts
|
|
265
|
+
async function getTokenizer(locale) {
|
|
266
|
+
return {
|
|
267
|
+
language: Object.keys(STEMMERS).find((lang) => STEMMERS[lang] === locale) ?? locale
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
async function initSimple(options) {
|
|
271
|
+
const map = /* @__PURE__ */ new Map();
|
|
272
|
+
if (options.i18n.languages.length === 0) {
|
|
273
|
+
return map;
|
|
274
|
+
}
|
|
275
|
+
const indexes = typeof options.indexes === "function" ? await options.indexes() : options.indexes;
|
|
276
|
+
for (const locale of options.i18n.languages) {
|
|
277
|
+
const localeIndexes = indexes.filter((index) => index.locale === locale);
|
|
278
|
+
const mapped = options.localeMap?.[locale] ?? await getTokenizer(locale);
|
|
279
|
+
map.set(
|
|
280
|
+
locale,
|
|
281
|
+
typeof mapped === "object" ? initSimpleSearch({
|
|
282
|
+
...options,
|
|
283
|
+
...mapped,
|
|
284
|
+
indexes: localeIndexes
|
|
285
|
+
}) : initSimpleSearch({
|
|
286
|
+
...options,
|
|
287
|
+
language: mapped,
|
|
288
|
+
indexes: localeIndexes
|
|
289
|
+
})
|
|
290
|
+
);
|
|
291
|
+
}
|
|
292
|
+
return map;
|
|
293
|
+
}
|
|
294
|
+
async function initAdvanced(options) {
|
|
295
|
+
const map = /* @__PURE__ */ new Map();
|
|
296
|
+
if (options.i18n.languages.length === 0) {
|
|
297
|
+
return map;
|
|
298
|
+
}
|
|
299
|
+
const indexes = typeof options.indexes === "function" ? await options.indexes() : options.indexes;
|
|
300
|
+
for (const locale of options.i18n.languages) {
|
|
301
|
+
const localeIndexes = indexes.filter((index) => index.locale === locale);
|
|
302
|
+
const mapped = options.localeMap?.[locale] ?? await getTokenizer(locale);
|
|
303
|
+
map.set(
|
|
304
|
+
locale,
|
|
305
|
+
typeof mapped === "object" ? initAdvancedSearch({
|
|
306
|
+
...options,
|
|
307
|
+
indexes: localeIndexes,
|
|
308
|
+
...mapped
|
|
309
|
+
}) : initAdvancedSearch({
|
|
310
|
+
...options,
|
|
311
|
+
language: mapped,
|
|
312
|
+
indexes: localeIndexes
|
|
313
|
+
})
|
|
314
|
+
);
|
|
315
|
+
}
|
|
316
|
+
return map;
|
|
317
|
+
}
|
|
318
|
+
function createI18nSearchAPI(type, options) {
|
|
319
|
+
const get = type === "simple" ? initSimple(options) : initAdvanced(options);
|
|
320
|
+
return createEndpoint({
|
|
321
|
+
async export() {
|
|
322
|
+
const map = await get;
|
|
323
|
+
const entries = Array.from(map.entries()).map(async ([k, v]) => [
|
|
324
|
+
k,
|
|
325
|
+
await v.export()
|
|
326
|
+
]);
|
|
327
|
+
return {
|
|
328
|
+
type: "i18n",
|
|
329
|
+
data: Object.fromEntries(await Promise.all(entries))
|
|
330
|
+
};
|
|
331
|
+
},
|
|
332
|
+
async search(query, searchOptions) {
|
|
333
|
+
const map = await get;
|
|
334
|
+
const locale = searchOptions?.locale ?? options.i18n.defaultLanguage;
|
|
335
|
+
const handler = map.get(locale);
|
|
336
|
+
if (handler) return handler.search(query, searchOptions);
|
|
337
|
+
return [];
|
|
338
|
+
}
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
// src/search/server.ts
|
|
343
|
+
function createSearchAPI(type, options) {
|
|
344
|
+
if (type === "simple") {
|
|
345
|
+
return createEndpoint(initSimpleSearch(options));
|
|
346
|
+
}
|
|
347
|
+
return createEndpoint(initAdvancedSearch(options));
|
|
348
|
+
}
|
|
349
|
+
function initSimpleSearch(options) {
|
|
350
|
+
const doc = createDBSimple(options);
|
|
351
|
+
return {
|
|
352
|
+
async export() {
|
|
353
|
+
return {
|
|
354
|
+
type: "simple",
|
|
355
|
+
...save(await doc)
|
|
356
|
+
};
|
|
357
|
+
},
|
|
358
|
+
async search(query) {
|
|
359
|
+
const db = await doc;
|
|
360
|
+
return searchSimple(db, query, options.search);
|
|
361
|
+
}
|
|
362
|
+
};
|
|
363
|
+
}
|
|
364
|
+
function initAdvancedSearch(options) {
|
|
365
|
+
const get = createDB(options);
|
|
366
|
+
return {
|
|
367
|
+
async export() {
|
|
368
|
+
return {
|
|
369
|
+
type: "advanced",
|
|
370
|
+
...save(await get)
|
|
371
|
+
};
|
|
372
|
+
},
|
|
373
|
+
async search(query, searchOptions) {
|
|
374
|
+
const db = await get;
|
|
375
|
+
const mode = searchOptions?.mode;
|
|
376
|
+
return searchAdvanced(db, query, searchOptions?.tag, {
|
|
377
|
+
...options.search,
|
|
378
|
+
mode: mode === "vector" ? "vector" : "fulltext"
|
|
379
|
+
}).catch((err) => {
|
|
380
|
+
if (mode === "vector") {
|
|
381
|
+
throw new Error(
|
|
382
|
+
"failed to search, make sure you have installed `@orama/plugin-embeddings` according to their docs.",
|
|
383
|
+
{
|
|
384
|
+
cause: err
|
|
385
|
+
}
|
|
386
|
+
);
|
|
387
|
+
}
|
|
388
|
+
throw err;
|
|
389
|
+
});
|
|
390
|
+
}
|
|
391
|
+
};
|
|
392
|
+
}
|
|
393
|
+
export {
|
|
394
|
+
createContentHighlighter,
|
|
395
|
+
createFromSource,
|
|
396
|
+
createI18nSearchAPI,
|
|
397
|
+
createSearchAPI,
|
|
398
|
+
initAdvancedSearch,
|
|
399
|
+
initSimpleSearch
|
|
400
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { R as Root } from '../../definitions-pJ7PybYY.js';
|
|
2
|
+
import 'react';
|
|
3
|
+
|
|
4
|
+
declare function deserializePageTree(root: Root): Root;
|
|
5
|
+
/**
|
|
6
|
+
* Deserialize data passed from server-side loader.
|
|
7
|
+
*
|
|
8
|
+
* It only receives the serialized data from server-side, hence not sharing plugins and some properties.
|
|
9
|
+
*/
|
|
10
|
+
declare function useFumadocsLoader<V extends {
|
|
11
|
+
pageTree?: object;
|
|
12
|
+
}>(serialized: V): {
|
|
13
|
+
pageTree: V["pageTree"] extends object ? Root : undefined;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export { deserializePageTree, useFumadocsLoader };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import {
|
|
2
|
+
visit
|
|
3
|
+
} from "../../chunk-L4JKQWCM.js";
|
|
4
|
+
import "../../chunk-U67V476Y.js";
|
|
5
|
+
|
|
6
|
+
// src/source/client/index.tsx
|
|
7
|
+
import { useMemo } from "react";
|
|
8
|
+
import { jsx } from "react/jsx-runtime";
|
|
9
|
+
function deserializePageTree(root) {
|
|
10
|
+
function deserializeHTML(html) {
|
|
11
|
+
return /* @__PURE__ */ jsx(
|
|
12
|
+
"span",
|
|
13
|
+
{
|
|
14
|
+
dangerouslySetInnerHTML: {
|
|
15
|
+
__html: html
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
visit(root, (item) => {
|
|
21
|
+
if ("icon" in item && typeof item.icon === "string") {
|
|
22
|
+
item.icon = deserializeHTML(item.icon);
|
|
23
|
+
}
|
|
24
|
+
if (typeof item.name === "string") {
|
|
25
|
+
item.name = deserializeHTML(item.name);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
return root;
|
|
29
|
+
}
|
|
30
|
+
function useFumadocsLoader(serialized) {
|
|
31
|
+
const { pageTree } = serialized;
|
|
32
|
+
return useMemo(() => {
|
|
33
|
+
return {
|
|
34
|
+
pageTree: pageTree ? deserializePageTree(pageTree) : void 0
|
|
35
|
+
};
|
|
36
|
+
}, [pageTree]);
|
|
37
|
+
}
|
|
38
|
+
export {
|
|
39
|
+
deserializePageTree,
|
|
40
|
+
useFumadocsLoader
|
|
41
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export { C as ContentStorage, p as ContentStorageFile, F as FileSystem, h as InferMetaType, I as InferPageType, b as LoaderConfig, c as LoaderOptions, f as LoaderOutput, L as LoaderPlugin, r as LoaderPluginOption, e as Meta, M as MetaData, d as Page, P as PageData, n as PageTreeBuilder, i as PageTreeBuilderContext, k as PageTreeOptions, j as PageTreeTransformer, R as ResolvedLoaderConfig, S as Source, a as SourceConfig, V as VirtualFile, _ as _ConfigUnion_, q as buildContentStorage, t as buildPlugins, g as createGetUrl, o as createPageTreeBuilder, l as loader, m as multiple, s as source, u as update } from '../loader-BvlPPJX0.js';
|
|
2
|
+
import '../definitions-pJ7PybYY.js';
|
|
3
|
+
import 'react';
|
|
4
|
+
import '../i18n/index.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Convert file path into slugs, also encode non-ASCII characters, so they can work in pathname
|
|
8
|
+
*/
|
|
9
|
+
declare function getSlugs(file: string): string[];
|
|
10
|
+
|
|
11
|
+
declare function basename(path: string, ext?: string): string;
|
|
12
|
+
declare function extname(path: string): string;
|
|
13
|
+
declare function dirname(path: string): string;
|
|
14
|
+
/**
|
|
15
|
+
* Split path into segments, trailing/leading slashes are removed
|
|
16
|
+
*/
|
|
17
|
+
declare function splitPath(path: string): string[];
|
|
18
|
+
/**
|
|
19
|
+
* Resolve paths, slashes within the path will be ignored
|
|
20
|
+
* @param paths - Paths to join
|
|
21
|
+
* @example
|
|
22
|
+
* ```
|
|
23
|
+
* ['a','b'] // 'a/b'
|
|
24
|
+
* ['/a'] // 'a'
|
|
25
|
+
* ['a', '/b'] // 'a/b'
|
|
26
|
+
* ['a', '../b/c'] // 'b/c'
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
declare function joinPath(...paths: string[]): string;
|
|
30
|
+
declare function slash(path: string): string;
|
|
31
|
+
|
|
32
|
+
declare const path_basename: typeof basename;
|
|
33
|
+
declare const path_dirname: typeof dirname;
|
|
34
|
+
declare const path_extname: typeof extname;
|
|
35
|
+
declare const path_joinPath: typeof joinPath;
|
|
36
|
+
declare const path_slash: typeof slash;
|
|
37
|
+
declare const path_splitPath: typeof splitPath;
|
|
38
|
+
declare namespace path {
|
|
39
|
+
export { path_basename as basename, path_dirname as dirname, path_extname as extname, path_joinPath as joinPath, path_slash as slash, path_splitPath as splitPath };
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export { path as PathUtils, getSlugs };
|