fumadocs-core 16.7.6 → 16.7.8

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.
Files changed (39) hide show
  1. package/dist/content/md.d.ts +2 -2
  2. package/dist/content/mdx/preset-bundler.d.ts +2 -2
  3. package/dist/content/mdx/preset-bundler.js +1 -1
  4. package/dist/content/mdx/preset-runtime.d.ts +2 -2
  5. package/dist/content/mdx/preset-runtime.js +1 -1
  6. package/dist/content/toc.d.ts +1 -1
  7. package/dist/dynamic-link.d.ts +2 -2
  8. package/dist/framework/index.d.ts +5 -5
  9. package/dist/framework/next.d.ts +2 -2
  10. package/dist/framework/react-router.d.ts +2 -2
  11. package/dist/framework/tanstack.d.ts +2 -2
  12. package/dist/framework/waku.d.ts +2 -2
  13. package/dist/highlight/index.d.ts +2 -2
  14. package/dist/i18n/middleware.d.ts +2 -2
  15. package/dist/link.d.ts +2 -2
  16. package/dist/mdx-plugins/index.d.ts +3 -3
  17. package/dist/mdx-plugins/rehype-code.d.ts +1 -1
  18. package/dist/mdx-plugins/rehype-toc.d.ts +1 -1
  19. package/dist/mdx-plugins/rehype-toc.js +75 -54
  20. package/dist/mdx-plugins/remark-admonition.js +1 -1
  21. package/dist/mdx-plugins/remark-feedback-block.js +1 -1
  22. package/dist/mdx-plugins/remark-heading.d.ts +1 -1
  23. package/dist/mdx-plugins/remark-heading.js +1 -1
  24. package/dist/mdx-plugins/remark-llms.js +1 -1
  25. package/dist/mdx-plugins/remark-steps.js +33 -14
  26. package/dist/mdx-plugins/remark-structure.js +1 -1
  27. package/dist/{rehype-code-DFx-xacR.d.ts → rehype-code-CMrTh9Lu.d.ts} +3 -3
  28. package/dist/{rehype-toc-DPrrpvXd.d.ts → rehype-toc-iWxg6ELI.d.ts} +1 -0
  29. package/dist/{remark-heading-cvYRraso.d.ts → remark-heading-95OQNNoH.d.ts} +2 -2
  30. package/dist/source/client/index.js +9 -1
  31. package/dist/source/index.js +1 -1
  32. package/dist/source/plugins/lucide-icons.js +1 -1
  33. package/dist/{toc-DjyooJ0-.d.ts → toc-CgnJPi4Q.d.ts} +6 -4
  34. package/dist/toc.d.ts +1 -1
  35. package/dist/toc.js +6 -5
  36. package/dist/{mdast-utils-9tJwoVTq.js → utils-C73VXFR0.js} +7 -2
  37. package/package.json +6 -7
  38. /package/dist/{icon-CfEtMzdP.js → icon-BpyLCZhB.js} +0 -0
  39. /package/dist/{util-BnfE-P1F.js → util-CT8y1EgJ.js} +0 -0
@@ -1,4 +1,4 @@
1
- import * as react from "react";
1
+ import * as _$react from "react";
2
2
  import { FC } from "react";
3
3
  import { Options } from "remark-rehype";
4
4
  import { Compatible } from "vfile";
@@ -25,6 +25,6 @@ declare function createMarkdownRenderer({
25
25
  remarkPlugins,
26
26
  remarkRehypeOptions
27
27
  }?: MarkdownRendererOptions): MarkdownRenderer;
28
- declare function Markdown(props: MarkdownProps & MarkdownRendererOptions): react.ReactNode | Promise<react.ReactNode>;
28
+ declare function Markdown(props: MarkdownProps & MarkdownRendererOptions): _$react.ReactNode | Promise<_$react.ReactNode>;
29
29
  //#endregion
30
30
  export { Markdown, MarkdownProps, MarkdownRenderer, MarkdownRendererOptions, createMarkdownRenderer };
@@ -1,7 +1,7 @@
1
- import { t as RehypeCodeOptions } from "../../rehype-code-DFx-xacR.js";
1
+ import { t as RehypeCodeOptions } from "../../rehype-code-CMrTh9Lu.js";
2
2
  import { t as RemarkImageOptions } from "../../remark-image-DQlJevNY.js";
3
3
  import { r as StructureOptions } from "../../remark-structure-c-gm2PCy.js";
4
- import { t as RemarkHeadingOptions } from "../../remark-heading-cvYRraso.js";
4
+ import { t as RemarkHeadingOptions } from "../../remark-heading-95OQNNoH.js";
5
5
  import { t as RemarkCodeTabOptions } from "../../remark-code-tab-Dk79zZwn.js";
6
6
  import { t as RemarkNpmOptions } from "../../remark-npm-7SDuqMc6.js";
7
7
  import { t as ResolvePlugins } from "../../util-D2LMvKsn.js";
@@ -1,4 +1,4 @@
1
- import { t as resolvePlugins } from "../../util-BnfE-P1F.js";
1
+ import { t as resolvePlugins } from "../../util-CT8y1EgJ.js";
2
2
  //#region src/content/mdx/preset-bundler.ts
3
3
  /**
4
4
  * apply MDX processor presets
@@ -1,7 +1,7 @@
1
- import { t as RehypeCodeOptions } from "../../rehype-code-DFx-xacR.js";
1
+ import { t as RehypeCodeOptions } from "../../rehype-code-CMrTh9Lu.js";
2
2
  import { t as RemarkImageOptions } from "../../remark-image-DQlJevNY.js";
3
3
  import { r as StructureOptions } from "../../remark-structure-c-gm2PCy.js";
4
- import { t as RemarkHeadingOptions } from "../../remark-heading-cvYRraso.js";
4
+ import { t as RemarkHeadingOptions } from "../../remark-heading-95OQNNoH.js";
5
5
  import { t as RemarkCodeTabOptions } from "../../remark-code-tab-Dk79zZwn.js";
6
6
  import { t as RemarkNpmOptions } from "../../remark-npm-7SDuqMc6.js";
7
7
  import { t as ResolvePlugins } from "../../util-D2LMvKsn.js";
@@ -1,4 +1,4 @@
1
- import { t as resolvePlugins } from "../../util-BnfE-P1F.js";
1
+ import { t as resolvePlugins } from "../../util-CT8y1EgJ.js";
2
2
  //#region src/content/mdx/preset-runtime.ts
3
3
  /**
4
4
  * apply MDX processor presets
@@ -1,4 +1,4 @@
1
- import { c as TOCItemType } from "../toc-DjyooJ0-.js";
1
+ import { c as TOCItemType } from "../toc-CgnJPi4Q.js";
2
2
  import { Compatible } from "vfile";
3
3
  import { PluggableList } from "unified";
4
4
 
@@ -1,5 +1,5 @@
1
1
  import { LinkProps } from "./link.js";
2
- import * as react from "react";
2
+ import * as _$react from "react";
3
3
 
4
4
  //#region src/dynamic-link.d.ts
5
5
  type DynamicLinkProps = LinkProps;
@@ -8,7 +8,7 @@ type DynamicLinkProps = LinkProps;
8
8
  *
9
9
  * It supports dynamic hrefs, which means you can use `/[lang]/my-page` with `dynamicHrefs` enabled
10
10
  */
11
- declare const DynamicLink: react.ForwardRefExoticComponent<LinkProps & react.RefAttributes<HTMLAnchorElement>>;
11
+ declare const DynamicLink: _$react.ForwardRefExoticComponent<LinkProps & _$react.RefAttributes<HTMLAnchorElement>>;
12
12
  declare function updateHref(href: string, params: Record<string, string | string[]>): string;
13
13
  //#endregion
14
14
  export { DynamicLink, DynamicLink as default, DynamicLinkProps, updateHref };
@@ -1,6 +1,6 @@
1
1
  import { ComponentProps, FC, ReactNode } from "react";
2
- import * as react_jsx_runtime0 from "react/jsx-runtime";
3
- import { StaticImport } from "next/dist/shared/lib/get-img-props";
2
+ import * as _$react_jsx_runtime0 from "react/jsx-runtime";
3
+ import { StaticImport } from "next/dist/shared/lib/get-img-props.js";
4
4
 
5
5
  //#region src/framework/index.d.ts
6
6
  interface ImageProps extends Omit<ComponentProps<'img'>, 'src'> {
@@ -39,11 +39,11 @@ declare function FrameworkProvider({
39
39
  children
40
40
  }: Framework & {
41
41
  children: ReactNode;
42
- }): react_jsx_runtime0.JSX.Element;
42
+ }): _$react_jsx_runtime0.JSX.Element;
43
43
  declare function usePathname(): string;
44
44
  declare function useRouter(): Router;
45
45
  declare function useParams(): Record<string, string | string[]>;
46
- declare function Image(props: ImageProps): react_jsx_runtime0.JSX.Element;
47
- declare function Link(props: LinkProps): react_jsx_runtime0.JSX.Element;
46
+ declare function Image(props: ImageProps): _$react_jsx_runtime0.JSX.Element;
47
+ declare function Link(props: LinkProps): _$react_jsx_runtime0.JSX.Element;
48
48
  //#endregion
49
49
  export { Framework, FrameworkProvider, Image, ImageProps, Link, Router, useParams, usePathname, useRouter };
@@ -1,6 +1,6 @@
1
1
  import { Framework } from "./index.js";
2
2
  import { ReactNode } from "react";
3
- import * as react_jsx_runtime0 from "react/jsx-runtime";
3
+ import * as _$react_jsx_runtime0 from "react/jsx-runtime";
4
4
 
5
5
  //#region src/framework/next.d.ts
6
6
  declare function NextProvider({
@@ -11,6 +11,6 @@ declare function NextProvider({
11
11
  children: ReactNode;
12
12
  Link?: Framework['Link'];
13
13
  Image?: Framework['Image'];
14
- }): react_jsx_runtime0.JSX.Element;
14
+ }): _$react_jsx_runtime0.JSX.Element;
15
15
  //#endregion
16
16
  export { NextProvider };
@@ -1,6 +1,6 @@
1
1
  import { Framework } from "./index.js";
2
2
  import { ReactNode } from "react";
3
- import * as react_jsx_runtime0 from "react/jsx-runtime";
3
+ import * as _$react_jsx_runtime0 from "react/jsx-runtime";
4
4
 
5
5
  //#region src/framework/react-router.d.ts
6
6
  declare function ReactRouterProvider({
@@ -11,6 +11,6 @@ declare function ReactRouterProvider({
11
11
  children: ReactNode;
12
12
  Link?: Framework['Link'];
13
13
  Image?: Framework['Image'];
14
- }): react_jsx_runtime0.JSX.Element;
14
+ }): _$react_jsx_runtime0.JSX.Element;
15
15
  //#endregion
16
16
  export { ReactRouterProvider };
@@ -1,6 +1,6 @@
1
1
  import { Framework } from "./index.js";
2
2
  import { ReactNode } from "react";
3
- import * as react_jsx_runtime0 from "react/jsx-runtime";
3
+ import * as _$react_jsx_runtime0 from "react/jsx-runtime";
4
4
 
5
5
  //#region src/framework/tanstack.d.ts
6
6
  /**
@@ -14,6 +14,6 @@ declare function TanstackProvider({
14
14
  children: ReactNode;
15
15
  Link?: Framework['Link'];
16
16
  Image?: Framework['Image'];
17
- }): react_jsx_runtime0.JSX.Element;
17
+ }): _$react_jsx_runtime0.JSX.Element;
18
18
  //#endregion
19
19
  export { TanstackProvider };
@@ -1,6 +1,6 @@
1
1
  import { Framework } from "./index.js";
2
2
  import { ReactNode } from "react";
3
- import * as react_jsx_runtime0 from "react/jsx-runtime";
3
+ import * as _$react_jsx_runtime0 from "react/jsx-runtime";
4
4
 
5
5
  //#region src/framework/waku.d.ts
6
6
  declare function WakuProvider({
@@ -11,6 +11,6 @@ declare function WakuProvider({
11
11
  children: ReactNode;
12
12
  Link?: Framework['Link'];
13
13
  Image?: Framework['Image'];
14
- }): react_jsx_runtime0.JSX.Element;
14
+ }): _$react_jsx_runtime0.JSX.Element;
15
15
  //#endregion
16
16
  export { WakuProvider };
@@ -1,7 +1,7 @@
1
1
  import { ReactNode } from "react";
2
2
  import { Components } from "hast-util-to-jsx-runtime";
3
3
  import { Root } from "hast";
4
- import * as shiki from "shiki";
4
+ import * as _$shiki from "shiki";
5
5
  import { BundledLanguage, BundledTheme, CodeOptionsMeta, CodeOptionsThemes, CodeToHastOptionsCommon, LanguageRegistration, ThemeRegistrationAny } from "shiki";
6
6
 
7
7
  //#region src/highlight/index.d.ts
@@ -27,7 +27,7 @@ declare function highlightHast(code: string, options: HighlightHastOptions): Pro
27
27
  declare function getHighlighter(engineType: 'js' | 'oniguruma', options?: {
28
28
  langs?: (BundledLanguage | LanguageRegistration)[];
29
29
  themes?: (BundledTheme | ThemeRegistrationAny)[];
30
- }): Promise<shiki.HighlighterCore>;
30
+ }): Promise<_$shiki.HighlighterCore>;
31
31
  declare function highlight(code: string, options: HighlightOptions): Promise<ReactNode>;
32
32
  //#endregion
33
33
  export { HighlightHastOptions, HighlightOptions, getHighlighter, highlight, highlightHast };
@@ -1,6 +1,6 @@
1
1
  import { t as I18nConfig } from "../index-DAzunKMp.js";
2
- import { NextProxy } from "next/server";
3
- import { NextURL } from "next/dist/server/web/next-url";
2
+ import { NextProxy } from "next/server.js";
3
+ import { NextURL } from "next/dist/server/web/next-url.js";
4
4
 
5
5
  //#region src/i18n/middleware.d.ts
6
6
  interface MiddlewareOptions extends I18nConfig {
package/dist/link.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import * as react from "react";
1
+ import * as _$react from "react";
2
2
  import { AnchorHTMLAttributes } from "react";
3
3
 
4
4
  //#region src/link.d.ts
@@ -14,6 +14,6 @@ interface LinkProps extends AnchorHTMLAttributes<HTMLAnchorElement> {
14
14
  */
15
15
  prefetch?: boolean;
16
16
  }
17
- declare const Link: react.ForwardRefExoticComponent<LinkProps & react.RefAttributes<HTMLAnchorElement>>;
17
+ declare const Link: _$react.ForwardRefExoticComponent<LinkProps & _$react.RefAttributes<HTMLAnchorElement>>;
18
18
  //#endregion
19
19
  export { LinkProps, Link as default };
@@ -1,12 +1,12 @@
1
1
  import { n as remarkGfm, t as RemarkGfmOptions } from "../remark-gfm-DIHBRjLx.js";
2
2
  import { a as CodeBlockIcon, i as transformerTab, o as transformerIcon } from "../rehype-code.core-AAMsXdqJ.js";
3
- import { n as rehypeCode, r as rehypeCodeDefaultOptions, t as RehypeCodeOptions } from "../rehype-code-DFx-xacR.js";
3
+ import { n as rehypeCode, r as rehypeCodeDefaultOptions, t as RehypeCodeOptions } from "../rehype-code-CMrTh9Lu.js";
4
4
  import { n as remarkImage, t as RemarkImageOptions } from "../remark-image-DQlJevNY.js";
5
5
  import { a as defaultStringifier, c as structure, i as StructuredData, n as StringifyOptions, o as remarkStructure, r as StructureOptions, s as remarkStructureDefaultOptions, t as Stringifier } from "../remark-structure-c-gm2PCy.js";
6
- import { n as remarkHeading, t as RemarkHeadingOptions } from "../remark-heading-cvYRraso.js";
6
+ import { n as remarkHeading, t as RemarkHeadingOptions } from "../remark-heading-95OQNNoH.js";
7
7
  import { n as remarkAdmonition, t as RemarkAdmonitionOptions } from "../remark-admonition-0gZM40ZU.js";
8
8
  import { n as remarkDirectiveAdmonition, t as RemarkDirectiveAdmonitionOptions } from "../remark-directive-admonition-CxFIkQ_i.js";
9
- import { n as RehypeTocOptions, r as rehypeToc, t as RehypeTOCItemType } from "../rehype-toc-DPrrpvXd.js";
9
+ import { n as RehypeTocOptions, r as rehypeToc, t as RehypeTOCItemType } from "../rehype-toc-iWxg6ELI.js";
10
10
  import { n as remarkCodeTab, t as RemarkCodeTabOptions } from "../remark-code-tab-Dk79zZwn.js";
11
11
  import { n as remarkSteps, t as RemarkStepsOptions } from "../remark-steps-DsnXM6Xj.js";
12
12
  import { n as remarkNpm, t as RemarkNpmOptions } from "../remark-npm-7SDuqMc6.js";
@@ -1,3 +1,3 @@
1
1
  import { a as CodeBlockIcon, i as transformerTab, o as transformerIcon } from "../rehype-code.core-AAMsXdqJ.js";
2
- import { n as rehypeCode, r as rehypeCodeDefaultOptions, t as RehypeCodeOptions } from "../rehype-code-DFx-xacR.js";
2
+ import { n as rehypeCode, r as rehypeCodeDefaultOptions, t as RehypeCodeOptions } from "../rehype-code-CMrTh9Lu.js";
3
3
  export { CodeBlockIcon, RehypeCodeOptions, rehypeCode, rehypeCodeDefaultOptions, transformerIcon, transformerTab };
@@ -1,2 +1,2 @@
1
- import { n as RehypeTocOptions, r as rehypeToc, t as RehypeTOCItemType } from "../rehype-toc-DPrrpvXd.js";
1
+ import { n as RehypeTocOptions, r as rehypeToc, t as RehypeTOCItemType } from "../rehype-toc-iWxg6ELI.js";
2
2
  export { RehypeTOCItemType, RehypeTocOptions, rehypeToc };
@@ -1,4 +1,4 @@
1
- import { r as toMdxExportRaw } from "../mdast-utils-9tJwoVTq.js";
1
+ import { i as toMdxExportRaw, n as handleTag } from "../utils-C73VXFR0.js";
2
2
  import { visit } from "unist-util-visit";
3
3
  import { toEstree } from "hast-util-to-estree";
4
4
  //#region src/mdx-plugins/rehype-toc.ts
@@ -27,19 +27,22 @@ function rehypeToc({ exportToc = true } = {}) {
27
27
  let isTocOnly = false;
28
28
  const last = element.children[element.children.length - 1];
29
29
  if (last.type === "text") {
30
- if (last.value.endsWith(NoTocTag)) {
31
- last.value = last.value.substring(0, last.value.length - 6).trimEnd();
30
+ const noToc = handleTag(last.value, NoTocTag);
31
+ if (noToc !== false) {
32
+ last.value = noToc;
32
33
  return "skip";
33
34
  }
34
- if (last.value.endsWith(TocOnlyTag)) {
35
+ const tocOnly = handleTag(last.value, TocOnlyTag);
36
+ if (tocOnly !== false) {
35
37
  isTocOnly = true;
36
- last.value = last.value.substring(0, last.value.length - 5).trimEnd();
38
+ last.value = tocOnly;
37
39
  }
38
40
  }
39
41
  items.push({
40
42
  title: element,
41
43
  depth: Number(element.tagName[1]),
42
- url: `#${id}`
44
+ url: `#${id}`,
45
+ _step: typeof element.properties["data-fd-step"] === "number" ? element.properties["data-fd-step"] : void 0
43
46
  });
44
47
  if (isTocOnly && parent && typeof idx === "number") parent.children.splice(idx, 1);
45
48
  return "skip";
@@ -58,58 +61,76 @@ function rehypeToc({ exportToc = true } = {}) {
58
61
  }
59
62
  tree.children.push(toMdxExportRaw(exportToc.name, {
60
63
  type: "ArrayExpression",
61
- elements: esmItems.map((item) => ({
62
- type: "ObjectExpression",
63
- properties: [
64
- {
65
- type: "Property",
66
- method: false,
67
- shorthand: false,
68
- computed: false,
69
- key: {
70
- type: "Identifier",
71
- name: "depth"
64
+ elements: esmItems.map((item) => {
65
+ const obj = {
66
+ type: "ObjectExpression",
67
+ properties: [
68
+ {
69
+ type: "Property",
70
+ method: false,
71
+ shorthand: false,
72
+ computed: false,
73
+ key: {
74
+ type: "Identifier",
75
+ name: "depth"
76
+ },
77
+ value: {
78
+ type: "Literal",
79
+ value: item.depth
80
+ },
81
+ kind: "init"
72
82
  },
73
- value: {
74
- type: "Literal",
75
- value: item.depth
83
+ {
84
+ type: "Property",
85
+ method: false,
86
+ shorthand: false,
87
+ computed: false,
88
+ key: {
89
+ type: "Identifier",
90
+ name: "url"
91
+ },
92
+ value: {
93
+ type: "Literal",
94
+ value: item.url
95
+ },
96
+ kind: "init"
76
97
  },
77
- kind: "init"
98
+ {
99
+ type: "Property",
100
+ method: false,
101
+ shorthand: false,
102
+ computed: false,
103
+ key: {
104
+ type: "Identifier",
105
+ name: "title"
106
+ },
107
+ value: {
108
+ type: "JSXFragment",
109
+ openingFragment: { type: "JSXOpeningFragment" },
110
+ closingFragment: { type: "JSXClosingFragment" },
111
+ children: item.title.children
112
+ },
113
+ kind: "init"
114
+ }
115
+ ]
116
+ };
117
+ if (typeof item._step === "number") obj.properties.push({
118
+ type: "Property",
119
+ method: false,
120
+ shorthand: false,
121
+ computed: false,
122
+ key: {
123
+ type: "Identifier",
124
+ name: "_step"
78
125
  },
79
- {
80
- type: "Property",
81
- method: false,
82
- shorthand: false,
83
- computed: false,
84
- key: {
85
- type: "Identifier",
86
- name: "url"
87
- },
88
- value: {
89
- type: "Literal",
90
- value: item.url
91
- },
92
- kind: "init"
126
+ value: {
127
+ type: "Literal",
128
+ value: item._step
93
129
  },
94
- {
95
- type: "Property",
96
- method: false,
97
- shorthand: false,
98
- computed: false,
99
- key: {
100
- type: "Identifier",
101
- name: "title"
102
- },
103
- value: {
104
- type: "JSXFragment",
105
- openingFragment: { type: "JSXOpeningFragment" },
106
- closingFragment: { type: "JSXClosingFragment" },
107
- children: item.title.children
108
- },
109
- kind: "init"
110
- }
111
- ]
112
- }))
130
+ kind: "init"
131
+ });
132
+ return obj;
133
+ })
113
134
  }));
114
135
  } else file.data.rehypeToc = items;
115
136
  };
@@ -1,4 +1,4 @@
1
- import { t as flattenNode } from "../mdast-utils-9tJwoVTq.js";
1
+ import { t as flattenNode } from "../utils-C73VXFR0.js";
2
2
  import { visit } from "unist-util-visit";
3
3
  //#region src/mdx-plugins/remark-admonition.ts
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { t as flattenNode } from "../mdast-utils-9tJwoVTq.js";
1
+ import { t as flattenNode } from "../utils-C73VXFR0.js";
2
2
  import { visit } from "unist-util-visit";
3
3
  import { createHash } from "node:crypto";
4
4
  //#region src/mdx-plugins/remark-feedback-block.ts
@@ -1,2 +1,2 @@
1
- import { n as remarkHeading, t as RemarkHeadingOptions } from "../remark-heading-cvYRraso.js";
1
+ import { n as remarkHeading, t as RemarkHeadingOptions } from "../remark-heading-95OQNNoH.js";
2
2
  export { RemarkHeadingOptions, remarkHeading };
@@ -1,4 +1,4 @@
1
- import { t as flattenNode } from "../mdast-utils-9tJwoVTq.js";
1
+ import { t as flattenNode } from "../utils-C73VXFR0.js";
2
2
  import Slugger from "github-slugger";
3
3
  import { visit } from "unist-util-visit";
4
4
  //#region src/mdx-plugins/remark-heading.ts
@@ -1,4 +1,4 @@
1
- import { n as toMdxExport } from "../mdast-utils-9tJwoVTq.js";
1
+ import { r as toMdxExport } from "../utils-C73VXFR0.js";
2
2
  import { defaultStringifier } from "./stringifier.js";
3
3
  //#region src/mdx-plugins/remark-llms.ts
4
4
  /**
@@ -1,6 +1,8 @@
1
+ import { n as handleTag } from "../utils-C73VXFR0.js";
1
2
  import { visit } from "unist-util-visit";
2
3
  //#region src/mdx-plugins/remark-steps.ts
3
4
  const StepRegex = /^(\d+)\.\s(.+)$/;
5
+ const StepTag = "[step]";
4
6
  /**
5
7
  * Convert headings in the format of `1. Hello World` into steps.
6
8
  */
@@ -27,16 +29,34 @@ function remarkSteps({ steps = "fd-steps", step = "fd-step" } = {}) {
27
29
  name: "className",
28
30
  value: steps
29
31
  }],
30
- data: { _fd_step: true },
31
32
  children
32
33
  };
33
34
  }
35
+ function handleHeadingStep(node) {
36
+ const head = node.children[0];
37
+ if (head && head.type === "text") {
38
+ const match = StepRegex.exec(head.value);
39
+ if (match) {
40
+ head.value = match[2];
41
+ return true;
42
+ }
43
+ }
44
+ const tail = node.children[node.children.length - 1];
45
+ if (tail && tail.type === "text") {
46
+ const step = handleTag(tail.value, StepTag);
47
+ if (step !== false) {
48
+ tail.value = step;
49
+ return true;
50
+ }
51
+ }
52
+ return false;
53
+ }
34
54
  return (tree) => {
35
55
  visit(tree, (parent) => {
36
- if (!("children" in parent) || parent.type === "heading") return;
37
- if (parent.data && "_fd_step" in parent.data) return "skip";
56
+ if (!("children" in parent) || parent.type === "heading") return "skip";
38
57
  let startIdx = -1;
39
58
  let i = 0;
59
+ let currentStep = 1;
40
60
  const onEnd = () => {
41
61
  if (startIdx === -1) return;
42
62
  const item = {};
@@ -44,26 +64,25 @@ function remarkSteps({ steps = "fd-steps", step = "fd-step" } = {}) {
44
64
  Object.assign(item, convertToSteps(nodes));
45
65
  i = startIdx + 1;
46
66
  startIdx = -1;
67
+ currentStep = 1;
47
68
  };
48
69
  for (; i < parent.children.length; i++) {
49
70
  const node = parent.children[i];
50
- if (node.type !== "heading") continue;
71
+ if (node.type !== "heading" || node.data?.hProperties?.["data-fd-step"] !== void 0) continue;
51
72
  if (startIdx !== -1) {
52
73
  const startDepth = parent.children[startIdx].depth;
53
- if (node.depth > startDepth) continue;
54
- else if (node.depth < startDepth) onEnd();
74
+ if (node.depth !== startDepth) {
75
+ if (node.depth < startDepth) onEnd();
76
+ continue;
77
+ }
55
78
  }
56
- const head = node.children.filter((c) => c.type === "text").at(0);
57
- if (!head) {
79
+ if (!handleHeadingStep(node)) {
58
80
  onEnd();
59
81
  continue;
60
82
  }
61
- const match = StepRegex.exec(head.value);
62
- if (!match) {
63
- onEnd();
64
- continue;
65
- }
66
- head.value = match[2];
83
+ node.data ??= {};
84
+ node.data.hProperties ??= {};
85
+ node.data.hProperties["data-fd-step"] = currentStep++;
67
86
  if (startIdx === -1) startIdx = i;
68
87
  }
69
88
  onEnd();
@@ -1,4 +1,4 @@
1
- import { n as toMdxExport } from "../mdast-utils-9tJwoVTq.js";
1
+ import { r as toMdxExport } from "../utils-C73VXFR0.js";
2
2
  import { remarkHeading } from "./remark-heading.js";
3
3
  import { defaultStringifier as defaultStringifier$1 } from "./stringifier.js";
4
4
  import { remark } from "remark";
@@ -1,6 +1,6 @@
1
1
  import { t as RehypeCodeOptionsCommon } from "./rehype-code.core-AAMsXdqJ.js";
2
- import * as unified from "unified";
3
- import * as hast from "hast";
2
+ import * as _$unified from "unified";
3
+ import * as _$hast from "hast";
4
4
 
5
5
  //#region src/mdx-plugins/rehype-code.d.ts
6
6
  type RehypeCodeOptions = RehypeCodeOptionsCommon & {
@@ -12,6 +12,6 @@ type RehypeCodeOptions = RehypeCodeOptionsCommon & {
12
12
  engine?: 'js' | 'oniguruma';
13
13
  };
14
14
  declare const rehypeCodeDefaultOptions: RehypeCodeOptions;
15
- declare const rehypeCode: (this: unified.Processor, _options?: Partial<RehypeCodeOptions> | undefined) => unified.Transformer<hast.Root, hast.Root>;
15
+ declare const rehypeCode: (this: _$unified.Processor, _options?: Partial<RehypeCodeOptions> | undefined) => _$unified.Transformer<_$hast.Root, _$hast.Root>;
16
16
  //#endregion
17
17
  export { rehypeCode as n, rehypeCodeDefaultOptions as r, RehypeCodeOptions as t };
@@ -37,6 +37,7 @@ interface RehypeTOCItemType {
37
37
  title: Element;
38
38
  url: string;
39
39
  depth: number;
40
+ _step?: number;
40
41
  }
41
42
  declare function rehypeToc(this: Processor, {
42
43
  exportToc
@@ -1,4 +1,4 @@
1
- import { c as TOCItemType } from "./toc-DjyooJ0-.js";
1
+ import { c as TOCItemType } from "./toc-CgnJPi4Q.js";
2
2
  import { Transformer } from "unified";
3
3
  import { Heading, Root } from "mdast";
4
4
 
@@ -7,7 +7,7 @@ declare module 'mdast' {
7
7
  interface HeadingData extends Data {
8
8
  hProperties?: {
9
9
  id?: string;
10
- };
10
+ } & Record<string, unknown>;
11
11
  }
12
12
  }
13
13
  interface RemarkHeadingOptions {
@@ -3,7 +3,15 @@ import { useMemo } from "react";
3
3
  import { jsx } from "react/jsx-runtime";
4
4
  //#region src/source/client/index.tsx
5
5
  function deserializeHTML(html) {
6
- return /* @__PURE__ */ jsx("span", { dangerouslySetInnerHTML: { __html: html } });
6
+ return /* @__PURE__ */ jsx("span", {
7
+ style: {
8
+ display: "inline-flex",
9
+ alignItems: "center",
10
+ gap: "4px",
11
+ width: "100%"
12
+ },
13
+ dangerouslySetInnerHTML: { __html: html }
14
+ });
7
15
  }
8
16
  function deserializePageTree(serialized) {
9
17
  const root = serialized.data;
@@ -2,7 +2,7 @@ import { t as normalizeUrl } from "../normalize-url-J3kqKlu4.js";
2
2
  import { c as visit } from "../utils-6GexS7iX.js";
3
3
  import { a as path_exports, i as joinPath, n as dirname, o as slash, r as extname, s as splitPath, t as basename } from "../path-CL7hf0GY.js";
4
4
  import { getSlugs, slugsPlugin } from "./plugins/slugs.js";
5
- import { t as iconPlugin } from "../icon-CfEtMzdP.js";
5
+ import { t as iconPlugin } from "../icon-BpyLCZhB.js";
6
6
  import path from "node:path";
7
7
  //#region src/source/source.ts
8
8
  function multiple(sources) {
@@ -1,4 +1,4 @@
1
- import { t as iconPlugin } from "../../icon-CfEtMzdP.js";
1
+ import { t as iconPlugin } from "../../icon-BpyLCZhB.js";
2
2
  import { createElement } from "react";
3
3
  import { icons } from "lucide-react";
4
4
  //#region src/source/plugins/lucide-icons.ts
@@ -1,11 +1,13 @@
1
1
  import { ComponentProps, ReactNode, RefObject } from "react";
2
- import * as react_jsx_runtime0 from "react/jsx-runtime";
2
+ import * as _$react_jsx_runtime0 from "react/jsx-runtime";
3
3
 
4
4
  //#region src/toc.d.ts
5
5
  interface TOCItemType {
6
6
  title: ReactNode;
7
7
  url: string;
8
8
  depth: number;
9
+ /** [remark-steps] the step number */
10
+ _step?: number;
9
11
  }
10
12
  type TableOfContents = TOCItemType[];
11
13
  interface TOCItemInfo {
@@ -38,12 +40,12 @@ interface ScrollProviderProps {
38
40
  declare function ScrollProvider({
39
41
  containerRef,
40
42
  children
41
- }: ScrollProviderProps): react_jsx_runtime0.JSX.Element;
43
+ }: ScrollProviderProps): _$react_jsx_runtime0.JSX.Element;
42
44
  declare function AnchorProvider({
43
45
  toc,
44
46
  single,
45
47
  children
46
- }: AnchorProviderProps): react_jsx_runtime0.JSX.Element;
48
+ }: AnchorProviderProps): _$react_jsx_runtime0.JSX.Element;
47
49
  interface TOCItemProps extends ComponentProps<'a'> {
48
50
  onActiveChange?: (v: boolean) => void;
49
51
  }
@@ -51,7 +53,7 @@ declare function TOCItem({
51
53
  ref,
52
54
  onActiveChange,
53
55
  ...props
54
- }: TOCItemProps): react_jsx_runtime0.JSX.Element;
56
+ }: TOCItemProps): _$react_jsx_runtime0.JSX.Element;
55
57
  /**
56
58
  * The estimated active heading ID
57
59
  */
package/dist/toc.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { a as TOCItem, c as TOCItemType, d as useActiveAnchors, f as useItems, i as ScrollProviderProps, l as TableOfContents, n as AnchorProviderProps, o as TOCItemInfo, r as ScrollProvider, s as TOCItemProps, t as AnchorProvider, u as useActiveAnchor } from "./toc-DjyooJ0-.js";
1
+ import { a as TOCItem, c as TOCItemType, d as useActiveAnchors, f as useItems, i as ScrollProviderProps, l as TableOfContents, n as AnchorProviderProps, o as TOCItemInfo, r as ScrollProvider, s as TOCItemProps, t as AnchorProvider, u as useActiveAnchor } from "./toc-CgnJPi4Q.js";
2
2
  export { AnchorProvider, AnchorProviderProps, ScrollProvider, ScrollProviderProps, TOCItem, TOCItemInfo, TOCItemProps, TOCItemType, TableOfContents, useActiveAnchor, useActiveAnchors, useItems };
package/dist/toc.js CHANGED
@@ -51,10 +51,11 @@ function TOCItem({ ref, onActiveChange = () => null, ...props }) {
51
51
  const id = props.href ? getItemId(props.href) : null;
52
52
  const anchorRef = useRef(null);
53
53
  const [active, setActive] = useState(() => id && items.some((item) => item.active && item.id === id));
54
- const initialShouldScroll = useMemo(() => {
54
+ const initialShouldScrollRef = useRef(null);
55
+ if (initialShouldScrollRef.current === null) {
55
56
  const lastActive = items.findLast((item) => item.active);
56
- return lastActive && lastActive.id === id;
57
- }, []);
57
+ initialShouldScrollRef.current = lastActive !== void 0 && lastActive.id === id;
58
+ }
58
59
  useOnChange(items, () => {
59
60
  if (id === null) return;
60
61
  const currentItem = items.find((item) => item.id === id);
@@ -74,14 +75,14 @@ function TOCItem({ ref, onActiveChange = () => null, ...props }) {
74
75
  useEffect(() => {
75
76
  const anchor = anchorRef.current;
76
77
  const container = containerRef?.current;
77
- if (initialShouldScroll && container && anchor) scrollIntoView(anchor, {
78
+ if (initialShouldScrollRef.current && container && anchor) scrollIntoView(anchor, {
78
79
  behavior: "instant",
79
80
  block: "center",
80
81
  inline: "center",
81
82
  scrollMode: "always",
82
83
  boundary: container
83
84
  });
84
- }, [containerRef, initialShouldScroll]);
85
+ }, [containerRef]);
85
86
  return /* @__PURE__ */ jsx("a", {
86
87
  ref: mergeRefs(anchorRef, ref),
87
88
  "data-active": active,
@@ -1,5 +1,5 @@
1
1
  import { valueToEstree } from "estree-util-value-to-estree";
2
- //#region src/mdx-plugins/mdast-utils.ts
2
+ //#region src/mdx-plugins/utils.ts
3
3
  function flattenNode(node) {
4
4
  if ("children" in node) return node.children.map((child) => flattenNode(child)).join("");
5
5
  if ("value" in node && typeof node.value === "string") return node.value;
@@ -35,5 +35,10 @@ function toMdxExportRaw(name, expression) {
35
35
  } }
36
36
  };
37
37
  }
38
+ function handleTag(value, tag) {
39
+ const idx = value.indexOf(tag);
40
+ if (idx !== -1) return value.slice(0, idx).trimEnd() + value.slice(idx + tag.length);
41
+ return false;
42
+ }
38
43
  //#endregion
39
- export { toMdxExport as n, toMdxExportRaw as r, flattenNode as t };
44
+ export { toMdxExportRaw as i, handleTag as n, toMdxExport as r, flattenNode as t };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fumadocs-core",
3
- "version": "16.7.6",
3
+ "version": "16.7.8",
4
4
  "description": "The React.js library for building a documentation website",
5
5
  "keywords": [
6
6
  "Docs",
@@ -129,7 +129,7 @@
129
129
  "mdast-util-to-markdown": "^2.1.2",
130
130
  "negotiator": "^1.0.0",
131
131
  "npm-to-yarn": "^3.0.1",
132
- "path-to-regexp": "^8.3.0",
132
+ "path-to-regexp": "^8.4.0",
133
133
  "remark": "^15.0.1",
134
134
  "remark-gfm": "^4.0.1",
135
135
  "remark-rehype": "^11.1.2",
@@ -145,7 +145,7 @@
145
145
  "@mixedbread/sdk": "^0.61.0",
146
146
  "@orama/core": "^1.2.19",
147
147
  "@oramacloud/client": "^2.1.4",
148
- "@tanstack/react-router": "1.168.3",
148
+ "@tanstack/react-router": "1.168.7",
149
149
  "@types/estree-jsx": "^1.0.5",
150
150
  "@types/hast": "^3.0.4",
151
151
  "@types/mdast": "^4.0.4",
@@ -155,17 +155,16 @@
155
155
  "@types/react-dom": "^19.2.3",
156
156
  "algoliasearch": "5.50.0",
157
157
  "flexsearch": "^0.8.212",
158
- "lucide-react": "^1.6.0",
158
+ "lucide-react": "^1.7.0",
159
159
  "next": "16.2.1",
160
160
  "react-router": "^7.13.2",
161
161
  "remark-directive": "^4.0.0",
162
162
  "remark-mdx": "^3.1.1",
163
163
  "remove-markdown": "^0.6.3",
164
- "tsdown": "0.21.5",
164
+ "tsdown": "0.21.6",
165
165
  "typescript": "^6.0.2",
166
166
  "waku": "1.0.0-alpha.6",
167
167
  "zod": "^4.3.6",
168
- "eslint-config-custom": "0.0.0",
169
168
  "tsconfig": "0.0.0"
170
169
  },
171
170
  "peerDependencies": {
@@ -248,7 +247,7 @@
248
247
  "build": "tsdown",
249
248
  "clean": "rimraf dist",
250
249
  "dev": "tsdown --watch --clean false",
251
- "lint": "eslint .",
250
+ "lint": "oxlint .",
252
251
  "types:check": "tsc --noEmit"
253
252
  }
254
253
  }
File without changes
File without changes