fumadocs-core 14.6.3 → 14.6.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.
@@ -2,7 +2,7 @@ import {
2
2
  removeUndefined
3
3
  } from "./chunk-2V6SCS43.js";
4
4
 
5
- // src/search/search/simple.ts
5
+ // src/search/orama/search/simple.ts
6
6
  import { search } from "@orama/orama";
7
7
  async function searchSimple(db, query, params = {}) {
8
8
  const result = await search(db, {
@@ -22,7 +22,7 @@ async function searchSimple(db, query, params = {}) {
22
22
  }));
23
23
  }
24
24
 
25
- // src/search/search/advanced.ts
25
+ // src/search/orama/search/advanced.ts
26
26
  import { getByID, search as search2 } from "@orama/orama";
27
27
  async function searchAdvanced(db, query, tag, extraParams = {}) {
28
28
  let params = {
@@ -0,0 +1,25 @@
1
+ import { ReactNode } from 'react';
2
+ import { PluggableList } from 'unified';
3
+ import { Compatible } from 'vfile';
4
+
5
+ interface TOCItemType {
6
+ title: ReactNode;
7
+ url: string;
8
+ depth: number;
9
+ }
10
+ type TableOfContents = TOCItemType[];
11
+ /**
12
+ * Get Table of Contents from markdown/mdx document (using remark)
13
+ *
14
+ * @param content - Markdown content or file
15
+ */
16
+ declare function getTableOfContents(content: Compatible): TableOfContents;
17
+ /**
18
+ * Get Table of Contents from markdown/mdx document (using remark)
19
+ *
20
+ * @param content - Markdown content or file
21
+ * @param remarkPlugins - remark plugins to be applied first
22
+ */
23
+ declare function getTableOfContents(content: Compatible, remarkPlugins: PluggableList): Promise<TableOfContents>;
24
+
25
+ export { type TableOfContents as T, type TOCItemType as a, getTableOfContents as g };
@@ -67,7 +67,7 @@ function useDocsSearch(client, locale, tag, delayMs = 100, allowEmpty = false, k
67
67
  const { searchDocs } = await import("../orama-cloud-QNHGN6SO.js");
68
68
  return searchDocs(debouncedValue, tag, client);
69
69
  }
70
- const { createStaticClient } = await import("../static-HJNGYVTY.js");
70
+ const { createStaticClient } = await import("../static-7O35FMI3.js");
71
71
  if (!staticClient) staticClient = createStaticClient(client);
72
72
  return staticClient.search(debouncedValue, locale, tag);
73
73
  }
@@ -19,9 +19,8 @@ declare const advancedSchema: {
19
19
  readonly tag: "string";
20
20
  readonly url: "string";
21
21
  };
22
-
23
- type SimpleDocument = TypedDocument<Orama<typeof schema>>;
24
- declare const schema: {
22
+ type SimpleDocument = TypedDocument<Orama<typeof simpleSchema>>;
23
+ declare const simpleSchema: {
25
24
  readonly url: "string";
26
25
  readonly title: "string";
27
26
  readonly description: "string";
@@ -83,7 +82,7 @@ interface SimpleOptions extends SharedOptions {
83
82
  /**
84
83
  * Customise search options on server
85
84
  */
86
- search?: Partial<SearchParams<Orama<typeof schema>, SimpleDocument>>;
85
+ search?: Partial<SearchParams<Orama<typeof simpleSchema>, SimpleDocument>>;
87
86
  }
88
87
  interface AdvancedOptions extends SharedOptions {
89
88
  indexes: AdvancedIndex[] | Dynamic<AdvancedIndex>;
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  searchAdvanced,
3
3
  searchSimple
4
- } from "../chunk-775SHR3E.js";
4
+ } from "../chunk-BO6MEAPT.js";
5
5
  import "../chunk-2V6SCS43.js";
6
6
  import "../chunk-MLKGABMK.js";
7
7
 
8
8
  // src/search/server.ts
9
9
  import { save } from "@orama/orama";
10
10
 
11
- // src/search/create-endpoint.ts
11
+ // src/search/orama/create-endpoint.ts
12
12
  function createEndpoint(server) {
13
13
  const { search } = server;
14
14
  return {
@@ -29,7 +29,7 @@ function createEndpoint(server) {
29
29
  };
30
30
  }
31
31
 
32
- // src/search/create-db.ts
32
+ // src/search/orama/create-db.ts
33
33
  import {
34
34
  create,
35
35
  insertMultiple
@@ -103,13 +103,7 @@ async function createDB({
103
103
  await insertMultiple(db, mapTo);
104
104
  return db;
105
105
  }
106
-
107
- // src/search/create-db-simple.ts
108
- import {
109
- create as create2,
110
- insertMultiple as insertMultiple2
111
- } from "@orama/orama";
112
- var schema = {
106
+ var simpleSchema = {
113
107
  url: "string",
114
108
  title: "string",
115
109
  description: "string",
@@ -122,14 +116,14 @@ async function createDBSimple({
122
116
  ...rest
123
117
  }) {
124
118
  const items = typeof indexes === "function" ? await indexes() : indexes;
125
- const db = await create2({
126
- schema,
119
+ const db = await create({
120
+ schema: simpleSchema,
127
121
  components: {
128
122
  tokenizer
129
123
  },
130
124
  ...rest
131
125
  });
132
- await insertMultiple2(
126
+ await insertMultiple(
133
127
  db,
134
128
  items.map((page) => ({
135
129
  title: page.title,
@@ -142,7 +136,7 @@ async function createDBSimple({
142
136
  return db;
143
137
  }
144
138
 
145
- // src/search/create-from-source.ts
139
+ // src/search/orama/create-from-source.ts
146
140
  function pageToIndex(page) {
147
141
  if (!("structuredData" in page.data)) {
148
142
  throw new Error(
@@ -180,7 +174,7 @@ function createFromSource(source, pageToIndexFn = pageToIndex, options = {}) {
180
174
  });
181
175
  }
182
176
 
183
- // src/search/_stemmers.ts
177
+ // src/search/orama/_stemmers.ts
184
178
  var STEMMERS = {
185
179
  arabic: "ar",
186
180
  armenian: "am",
@@ -213,7 +207,7 @@ var STEMMERS = {
213
207
  sanskrit: "sk"
214
208
  };
215
209
 
216
- // src/search/i18n-api.ts
210
+ // src/search/orama/create-i18n.ts
217
211
  function defaultLocaleMap(locale) {
218
212
  const map = STEMMERS;
219
213
  return Object.keys(map).find((lang) => map[lang] === locale) ?? locale;
@@ -318,7 +312,7 @@ function initAdvancedSearch(options) {
318
312
  async export() {
319
313
  return {
320
314
  type: "advanced",
321
- ...save(await get)
315
+ ...await save(await get)
322
316
  };
323
317
  },
324
318
  async search(query, searchOptions) {
@@ -1,4 +1,4 @@
1
- export { a as TOCItemType, T as TableOfContents, g as getTableOfContents } from '../get-toc-Dm1yr2Gr.js';
1
+ export { a as TOCItemType, T as TableOfContents, g as getTableOfContents } from '../get-toc-Cr2URuiP.js';
2
2
  import { N as Node, I as Item, R as Root } from '../page-tree-r8qjoUla.js';
3
3
  export { p as PageTree } from '../page-tree-r8qjoUla.js';
4
4
  export { S as SortedResult } from '../types-Ch8gnVgO.js';
@@ -7,6 +7,8 @@ import { NextRequest } from 'next/server';
7
7
  import { LoaderOutput, LoaderConfig, InferPageType } from '../source/index.js';
8
8
  export { H as HighlightOptions, c as createStyleTransformer, h as highlight } from '../shiki-CNmCR8Td.js';
9
9
  import 'react';
10
+ import 'unified';
11
+ import 'vfile';
10
12
  import '../config-inq6kP6y.js';
11
13
  import 'shiki';
12
14
  import 'shiki/themes';
@@ -9,7 +9,13 @@ import "../chunk-MLKGABMK.js";
9
9
 
10
10
  // src/server/get-toc.ts
11
11
  import { remark } from "remark";
12
- function getTableOfContents(content) {
12
+ function getTableOfContents(content, remarkPlugins) {
13
+ if (remarkPlugins) {
14
+ return remark().use(remarkPlugins).use(remarkHeading).process(content).then((result2) => {
15
+ if ("toc" in result2.data) return result2.data.toc;
16
+ return [];
17
+ });
18
+ }
13
19
  const result = remark().use(remarkHeading).processSync(content);
14
20
  if ("toc" in result.data) return result.data.toc;
15
21
  return [];
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  searchAdvanced,
3
3
  searchSimple
4
- } from "./chunk-775SHR3E.js";
4
+ } from "./chunk-BO6MEAPT.js";
5
5
  import "./chunk-2V6SCS43.js";
6
6
  import "./chunk-MLKGABMK.js";
7
7
 
@@ -46,7 +46,10 @@ function createStaticClient({
46
46
  const cached = dbs.get(locale ?? "");
47
47
  if (!cached) return [];
48
48
  if (cached.type === "simple")
49
- return searchSimple(cached, query);
49
+ return searchSimple(
50
+ cached,
51
+ query
52
+ );
50
53
  return searchAdvanced(
51
54
  cached.db,
52
55
  query,
package/dist/toc.d.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  import * as react from 'react';
2
2
  import { ReactNode, RefObject, AnchorHTMLAttributes } from 'react';
3
- import { T as TableOfContents } from './get-toc-Dm1yr2Gr.js';
3
+ import { T as TableOfContents } from './get-toc-Cr2URuiP.js';
4
+ import 'unified';
5
+ import 'vfile';
4
6
 
5
7
  /**
6
8
  * The estimated active heading ID
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fumadocs-core",
3
- "version": "14.6.3",
3
+ "version": "14.6.5",
4
4
  "description": "The library for building a documentation website in Next.js",
5
5
  "keywords": [
6
6
  "NextJs",
@@ -108,6 +108,7 @@
108
108
  "shiki-transformers": "^1.0.1",
109
109
  "typescript": "^5.7.2",
110
110
  "unified": "^11.0.5",
111
+ "vfile": "^6.0.3",
111
112
  "eslint-config-custom": "0.0.0",
112
113
  "tsconfig": "0.0.0"
113
114
  },
@@ -1,16 +0,0 @@
1
- import { ReactNode } from 'react';
2
-
3
- interface TOCItemType {
4
- title: ReactNode;
5
- url: string;
6
- depth: number;
7
- }
8
- type TableOfContents = TOCItemType[];
9
- /**
10
- * Get Table of Contents from markdown/mdx document (using remark)
11
- *
12
- * @param content - Markdown content
13
- */
14
- declare function getTableOfContents(content: string): TableOfContents;
15
-
16
- export { type TableOfContents as T, type TOCItemType as a, getTableOfContents as g };