fumadocs-core 16.8.9 → 16.8.10

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.
@@ -30,7 +30,10 @@ declare class FileSystem<File> {
30
30
  }
31
31
  //#endregion
32
32
  //#region src/source/storage/content.d.ts
33
- type ContentStorage<P = ContentStoragePageFile, M = ContentStorageMetaFile> = FileSystem<P | M>;
33
+ type ContentStorage<P extends ContentStoragePageFile = ContentStoragePageFile, M extends ContentStorageMetaFile = ContentStorageMetaFile> = FileSystem<P | M> & {
34
+ /** always `undefined`, for inferring types only */$inferPage: P; /** always `undefined`, for inferring types only */
35
+ $inferMeta: M;
36
+ };
34
37
  /** @internal */
35
38
  interface ContentStorageMetaFile<Type extends string | undefined = string | undefined, Data extends MetaData = MetaData> {
36
39
  type: Type;
@@ -125,7 +128,7 @@ declare class PageTreeBuilder {
125
128
  /**
126
129
  * a function to generate slugs, return `undefined` to fallback to default generation.
127
130
  */
128
- type SlugFn<S = ContentStorage> = (file: S extends ContentStorage<infer P, unknown> ? P : never) => string[] | undefined;
131
+ type SlugFn<S extends ContentStorage = ContentStorage> = (file: S['$inferPage']) => string[] | undefined;
129
132
  /**
130
133
  * Generate slugs for pages if missing
131
134
  */
@@ -0,0 +1,42 @@
1
+ import { Transformer } from "unified";
2
+ import { Root, RootContent } from "mdast";
3
+
4
+ //#region src/mdx-plugins/remark-block-id.d.ts
5
+ interface RemarkBlockIdOptions {
6
+ /**
7
+ * generate block ID.
8
+ */
9
+ generateId?: (ctx: {
10
+ node: RootContent;
11
+ text: string;
12
+ }) => string;
13
+ /**
14
+ * determine whether an ID should be generated for a given node.
15
+ *
16
+ * default: `true` for block nodes, otherwise `false`.
17
+ *
18
+ * @returns
19
+ * - `true`: generate an ID for the node.
20
+ * - `false`: skip the current node and look into its children.
21
+ * - `skip`: skip the current node and its children.
22
+ */
23
+ shouldGenerate?: (node: RootContent) => boolean | 'skip';
24
+ /**
25
+ * Add `data-block="<value>"` to updated nodes, pass `null` to disable.
26
+ *
27
+ * @default "default"
28
+ */
29
+ addDataAttribute?: string | null;
30
+ }
31
+ /**
32
+ * Generate ID for each block node in Markdown/MDX.
33
+ *
34
+ * Note: the uniqueness is only guaranteed per file.
35
+ */
36
+ declare function remarkBlockId({
37
+ generateId,
38
+ addDataAttribute,
39
+ shouldGenerate
40
+ }?: RemarkBlockIdOptions): Transformer<Root, Root>;
41
+ //#endregion
42
+ export { RemarkBlockIdOptions, remarkBlockId };
@@ -0,0 +1,41 @@
1
+ import { t as flattenNode } from "../utils-pSG8hSr9.js";
2
+ import Slugger from "github-slugger";
3
+ import { visit } from "unist-util-visit";
4
+ import { createHash } from "node:crypto";
5
+ //#region src/mdx-plugins/remark-block-id.ts
6
+ /**
7
+ * Generate ID for each block node in Markdown/MDX.
8
+ *
9
+ * Note: the uniqueness is only guaranteed per file.
10
+ */
11
+ function remarkBlockId({ generateId, addDataAttribute = "default", shouldGenerate = (node) => {
12
+ switch (node.type) {
13
+ case "mdxJsxFlowElement": return "skip";
14
+ case "paragraph":
15
+ case "image":
16
+ case "listItem": return true;
17
+ default: return false;
18
+ }
19
+ } } = {}) {
20
+ return (tree) => {
21
+ const slugger = new Slugger();
22
+ visit(tree, (node) => {
23
+ if (node.type === "root" || node.data?.hProperties?.id) return;
24
+ const resolved = shouldGenerate(node);
25
+ if (resolved === false) return;
26
+ if (resolved === "skip") return "skip";
27
+ const text = flattenNode(node).trim();
28
+ if (text.length === 0) return;
29
+ const id = generateId ? slugger.slug(generateId({
30
+ node,
31
+ text
32
+ })) : slugger.slug(createHash("sha256").update(text).digest("base64url"));
33
+ node.data ??= {};
34
+ node.data.hProperties ??= {};
35
+ node.data.hProperties.id = id;
36
+ if (addDataAttribute) node.data.hProperties["data-block"] = addDataAttribute;
37
+ });
38
+ };
39
+ }
40
+ //#endregion
41
+ export { remarkBlockId };
@@ -1,7 +1,7 @@
1
1
  import { t as Awaitable } from "../types-DpbpliNk.js";
2
2
  import { t as I18nConfig } from "../index-DaiDEfiL.js";
3
- import { m as SharedIndex, n as SearchAPI, t as QueryOptions } from "../server-CG7-_iKC.js";
4
- import { C as LoaderConfig, T as LoaderOutput } from "../index-Ceg2efJm.js";
3
+ import { m as SharedIndex, n as SearchAPI, t as QueryOptions } from "../server-DZLj6URC.js";
4
+ import { C as LoaderConfig, T as LoaderOutput } from "../index-DvNKidQF.js";
5
5
  import { DocumentData, DocumentOptions } from "flexsearch";
6
6
 
7
7
  //#region src/search/server/build-doc.d.ts
@@ -1,5 +1,5 @@
1
1
  import { r as SortedResult } from "../index-CnkxgKNd.js";
2
- import { n as SearchAPI } from "../server-CG7-_iKC.js";
2
+ import { n as SearchAPI } from "../server-DZLj6URC.js";
3
3
  import Mixedbread from "@mixedbread/sdk";
4
4
  import { StoreSearchResponse } from "@mixedbread/sdk/resources/stores";
5
5
 
@@ -1,2 +1,2 @@
1
- import { a as AdvancedOptions, c as SimpleOptions, d as createSearchAPI, f as initAdvancedSearch, i as AdvancedIndex, l as createFromSource, n as SearchAPI, o as ExportedData, p as initSimpleSearch, r as SearchServer, s as Index, t as QueryOptions, u as createI18nSearchAPI } from "../server-CG7-_iKC.js";
1
+ import { a as AdvancedOptions, c as SimpleOptions, d as createSearchAPI, f as initAdvancedSearch, i as AdvancedIndex, l as createFromSource, n as SearchAPI, o as ExportedData, p as initSimpleSearch, r as SearchServer, s as Index, t as QueryOptions, u as createI18nSearchAPI } from "../server-DZLj6URC.js";
2
2
  export { AdvancedIndex, AdvancedOptions, ExportedData, Index, QueryOptions, SearchAPI, SearchServer, SimpleOptions, createFromSource, createI18nSearchAPI, createSearchAPI, initAdvancedSearch, initSimpleSearch };
@@ -2,7 +2,7 @@ import { t as Awaitable } from "./types-DpbpliNk.js";
2
2
  import { i as StructuredData } from "./remark-structure-C2-K9_ko.js";
3
3
  import { t as I18nConfig } from "./index-DaiDEfiL.js";
4
4
  import { r as SortedResult } from "./index-CnkxgKNd.js";
5
- import { C as LoaderConfig, T as LoaderOutput } from "./index-Ceg2efJm.js";
5
+ import { C as LoaderConfig, T as LoaderOutput } from "./index-DvNKidQF.js";
6
6
  import { Language, Orama, RawData, SearchParams, TypedDocument, create } from "@orama/orama";
7
7
 
8
8
  //#region src/search/orama/create-db.d.ts
@@ -1,2 +1,2 @@
1
- import { b as dynamicLoader, v as DynamicLoader, y as DynamicLoaderConfig } from "../index-Ceg2efJm.js";
1
+ import { b as dynamicLoader, v as DynamicLoader, y as DynamicLoaderConfig } from "../index-DvNKidQF.js";
2
2
  export { DynamicLoader, DynamicLoaderConfig, dynamicLoader };
@@ -1,2 +1,2 @@
1
- import { A as ResolvedLoaderConfig, B as PageTreeTransformer, C as LoaderConfig, D as LoaderPluginOption, E as LoaderPlugin, H as ContentStorageMetaFile, L as PageTreeBuilder, M as loader, O as Meta, P as getSlugs, R as PageTreeBuilderContext, S as InferPageType, T as LoaderOutput, U as ContentStoragePageFile, V as ContentStorage, W as FileSystem, _ as update, a as MetaData, c as SourceConfig, d as VirtualFile, f as _SourceUpdate_, g as source, h as multiple, i as DynamicSource, j as createGetUrl, k as Page, l as SourceUnion, m as isStaticSource, n as llms, o as PageData, p as isDynamicSource, r as path_d_exports, s as Source, t as LLMsConfig, u as StaticSource, w as LoaderOptions, x as InferMetaType, z as PageTreeOptions } from "../index-Ceg2efJm.js";
1
+ import { A as ResolvedLoaderConfig, B as PageTreeTransformer, C as LoaderConfig, D as LoaderPluginOption, E as LoaderPlugin, H as ContentStorageMetaFile, L as PageTreeBuilder, M as loader, O as Meta, P as getSlugs, R as PageTreeBuilderContext, S as InferPageType, T as LoaderOutput, U as ContentStoragePageFile, V as ContentStorage, W as FileSystem, _ as update, a as MetaData, c as SourceConfig, d as VirtualFile, f as _SourceUpdate_, g as source, h as multiple, i as DynamicSource, j as createGetUrl, k as Page, l as SourceUnion, m as isStaticSource, n as llms, o as PageData, p as isDynamicSource, r as path_d_exports, s as Source, t as LLMsConfig, u as StaticSource, w as LoaderOptions, x as InferMetaType, z as PageTreeOptions } from "../index-DvNKidQF.js";
2
2
  export { ContentStorage, ContentStorageMetaFile, ContentStoragePageFile, DynamicSource, FileSystem, InferMetaType, InferPageType, LLMsConfig, LoaderConfig, LoaderOptions, LoaderOutput, LoaderPlugin, LoaderPluginOption, Meta, MetaData, Page, PageData, PageTreeBuilder, PageTreeBuilderContext, PageTreeOptions, PageTreeTransformer, path_d_exports as PathUtils, ResolvedLoaderConfig, Source, SourceConfig, SourceUnion, StaticSource, VirtualFile, _SourceUpdate_, createGetUrl, getSlugs, isDynamicSource, isStaticSource, llms, loader, multiple, source, update };
@@ -1,2 +1,2 @@
1
- import { n as llms, t as LLMsConfig } from "../index-Ceg2efJm.js";
1
+ import { n as llms, t as LLMsConfig } from "../index-DvNKidQF.js";
2
2
  export { LLMsConfig, llms };
@@ -1,4 +1,4 @@
1
- import { E as LoaderPlugin } from "../../index-Ceg2efJm.js";
1
+ import { E as LoaderPlugin } from "../../index-DvNKidQF.js";
2
2
  import { icons } from "lucide-react";
3
3
 
4
4
  //#region src/source/plugins/lucide-icons.d.ts
@@ -1,2 +1,2 @@
1
- import { F as slugsFromData, I as slugsPlugin, N as SlugFn, P as getSlugs } from "../../index-Ceg2efJm.js";
1
+ import { F as slugsFromData, I as slugsPlugin, N as SlugFn, P as getSlugs } from "../../index-DvNKidQF.js";
2
2
  export { SlugFn, getSlugs, slugsFromData, slugsPlugin };
@@ -1,5 +1,5 @@
1
1
  import { a as Separator$1, n as Item$1, t as Folder$1 } from "../../definitions-Cob-Q8-8.js";
2
- import { E as LoaderPlugin } from "../../index-Ceg2efJm.js";
2
+ import { E as LoaderPlugin } from "../../index-DvNKidQF.js";
3
3
  import { ReactNode } from "react";
4
4
 
5
5
  //#region src/source/plugins/status-badges.d.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fumadocs-core",
3
- "version": "16.8.9",
3
+ "version": "16.8.10",
4
4
  "description": "The React.js library for building a documentation website",
5
5
  "keywords": [
6
6
  "Docs",
@@ -42,6 +42,7 @@
42
42
  "./mdx-plugins/rehype-code.core": "./dist/mdx-plugins/rehype-code.core.js",
43
43
  "./mdx-plugins/rehype-toc": "./dist/mdx-plugins/rehype-toc.js",
44
44
  "./mdx-plugins/remark-admonition": "./dist/mdx-plugins/remark-admonition.js",
45
+ "./mdx-plugins/remark-block-id": "./dist/mdx-plugins/remark-block-id.js",
45
46
  "./mdx-plugins/remark-code-tab": "./dist/mdx-plugins/remark-code-tab.js",
46
47
  "./mdx-plugins/remark-directive-admonition": "./dist/mdx-plugins/remark-directive-admonition.js",
47
48
  "./mdx-plugins/remark-feedback-block": "./dist/mdx-plugins/remark-feedback-block.js",