fumadocs-core 16.10.7 → 16.11.0

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.
@@ -25,12 +25,12 @@ declare function generateCodeBlockTabs({
25
25
  ...options
26
26
  }: CodeBlockTabsOptions): MdxJsxFlowElement;
27
27
  interface CodeBlockAttributes<Name extends string = string> {
28
- attributes: Partial<Record<Name, string | null>>;
28
+ attributes: Partial<Record<Name, string | number | null>>;
29
29
  rest: string;
30
30
  }
31
31
  /**
32
32
  * Parse Fumadocs-style code block attributes from meta string, like `title="hello world"`
33
33
  */
34
- declare function parseCodeBlockAttributes<Name extends string = string>(meta: string, allowedNames?: Name[]): CodeBlockAttributes<Name>;
34
+ declare function parseCodeBlockAttributes<const Name extends string = string>(meta: string, allowedNames?: Name[]): CodeBlockAttributes<Name>;
35
35
  //#endregion
36
36
  export { parseCodeBlockAttributes as i, CodeBlockTabsOptions as n, generateCodeBlockTabs as r, CodeBlockAttributes as t };
@@ -7,7 +7,11 @@ type DynamicLinkProps = LinkProps;
7
7
  *
8
8
  * It supports dynamic hrefs, which means you can use `/[lang]/my-page` with `dynamicHrefs` enabled
9
9
  */
10
- declare const DynamicLink: import("react").ForwardRefExoticComponent<LinkProps & import("react").RefAttributes<HTMLAnchorElement>>;
10
+ declare function DynamicLink({
11
+ href,
12
+ ref,
13
+ ...props
14
+ }: DynamicLinkProps): import("react").JSX.Element;
11
15
  declare function updateHref(href: string, params: Record<string, string | string[]>): string;
12
16
  //#endregion
13
17
  export { DynamicLink, DynamicLink as default, DynamicLinkProps, updateHref };
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { useParams } from "./framework/index.js";
3
- import Link from "./link.js";
4
- import { forwardRef, useMemo } from "react";
3
+ import { Link } from "./link.js";
4
+ import { useMemo } from "react";
5
5
  import { jsx } from "react/jsx-runtime";
6
6
  //#region src/dynamic-link.tsx
7
7
  /**
@@ -9,15 +9,14 @@ import { jsx } from "react/jsx-runtime";
9
9
  *
10
10
  * It supports dynamic hrefs, which means you can use `/[lang]/my-page` with `dynamicHrefs` enabled
11
11
  */
12
- const DynamicLink = forwardRef(({ href, ...props }, ref) => {
12
+ function DynamicLink({ href, ref, ...props }) {
13
13
  const params = useParams();
14
14
  return /* @__PURE__ */ jsx(Link, {
15
15
  ref,
16
16
  href: useMemo(() => href ? updateHref(href, params) : href, [params, href]),
17
17
  ...props
18
18
  });
19
- });
20
- DynamicLink.displayName = "DynamicLink";
19
+ }
21
20
  function updateHref(href, params) {
22
21
  return href.replace(/\[(.*)]\/?/, (match, key) => {
23
22
  const hasEndingSlash = match[match.length - 1] === "/";
@@ -11,20 +11,21 @@ const FrameworkContext = createContext({
11
11
  usePathname: notImplemented
12
12
  });
13
13
  function FrameworkProvider({ Link, useRouter, useParams, usePathname, Image, children }) {
14
+ const framework = useMemo(() => ({
15
+ usePathname,
16
+ useRouter,
17
+ Link,
18
+ Image,
19
+ useParams
20
+ }), [
21
+ Link,
22
+ usePathname,
23
+ useRouter,
24
+ useParams,
25
+ Image
26
+ ]);
14
27
  return /* @__PURE__ */ jsx(FrameworkContext, {
15
- value: useMemo(() => ({
16
- usePathname,
17
- useRouter,
18
- Link,
19
- Image,
20
- useParams
21
- }), [
22
- Link,
23
- usePathname,
24
- useRouter,
25
- useParams,
26
- Image
27
- ]),
28
+ value: framework,
28
29
  children
29
30
  });
30
31
  }
package/dist/link.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { AnchorHTMLAttributes } from "react";
1
+ import { ComponentProps } from "react";
2
2
 
3
3
  //#region src/link.d.ts
4
- interface LinkProps extends AnchorHTMLAttributes<HTMLAnchorElement> {
4
+ interface LinkProps extends ComponentProps<'a'> {
5
5
  /**
6
6
  * If the href is an external URL
7
7
  *
@@ -13,6 +13,13 @@ interface LinkProps extends AnchorHTMLAttributes<HTMLAnchorElement> {
13
13
  */
14
14
  prefetch?: boolean;
15
15
  }
16
- declare const Link: import("react").ForwardRefExoticComponent<LinkProps & import("react").RefAttributes<HTMLAnchorElement>>;
16
+ declare function Link({
17
+ ref,
18
+ href,
19
+ external,
20
+ prefetch,
21
+ children,
22
+ ...props
23
+ }: LinkProps): import("react").JSX.Element;
17
24
  //#endregion
18
- export { LinkProps, Link as default };
25
+ export { Link, Link as default, LinkProps };
package/dist/link.js CHANGED
@@ -1,9 +1,8 @@
1
1
  "use client";
2
2
  import { Link as Link$1 } from "./framework/index.js";
3
- import { forwardRef } from "react";
4
3
  import { jsx } from "react/jsx-runtime";
5
4
  //#region src/link.tsx
6
- const Link = forwardRef(({ href = "#", external = href.match(/^\w+:/) || href.startsWith("//"), prefetch, children, ...props }, ref) => {
5
+ function Link({ ref, href = "#", external = !!(href.match(/^\w+:/) || href.startsWith("//")), prefetch, children, ...props }) {
7
6
  if (external) return /* @__PURE__ */ jsx("a", {
8
7
  ref,
9
8
  href,
@@ -19,7 +18,6 @@ const Link = forwardRef(({ href = "#", external = href.match(/^\w+:/) || href.st
19
18
  ...props,
20
19
  children
21
20
  });
22
- });
23
- Link.displayName = "Link";
21
+ }
24
22
  //#endregion
25
- export { Link as default };
23
+ export { Link, Link as default };
@@ -1,2 +1,2 @@
1
- import { i as parseCodeBlockAttributes, n as CodeBlockTabsOptions, r as generateCodeBlockTabs, t as CodeBlockAttributes } from "../codeblock-utils-B5pyK6c4.js";
1
+ import { i as parseCodeBlockAttributes, n as CodeBlockTabsOptions, r as generateCodeBlockTabs, t as CodeBlockAttributes } from "../codeblock-utils-B92t2Hm-.js";
2
2
  export { CodeBlockAttributes, CodeBlockTabsOptions, generateCodeBlockTabs, parseCodeBlockAttributes };
@@ -48,16 +48,17 @@ function generateCodeBlockTabs({ persist = false, defaultValue, triggers, tabs,
48
48
  children
49
49
  };
50
50
  }
51
- const AttributeRegex = /(?<=^|\s)(?<name>[a-zA-Z0-9_-]+)(?:=(?:"([^"]*)"|'([^']*)'))?/g;
51
+ const AttributeRegex = /(?<=^|\s)(?<name>[a-zA-Z0-9_-]+)(?:=(?:"([^"]*)"|'([^']*)'|(\d+)))?/g;
52
52
  /**
53
53
  * Parse Fumadocs-style code block attributes from meta string, like `title="hello world"`
54
54
  */
55
55
  function parseCodeBlockAttributes(meta, allowedNames) {
56
56
  const attributes = {};
57
57
  return {
58
- rest: meta.replaceAll(AttributeRegex, (match, name, value_1, value_2) => {
58
+ rest: meta.replaceAll(AttributeRegex, (match, name, value_1, value_2, value_3) => {
59
59
  if (allowedNames && !allowedNames.includes(name)) return match;
60
- attributes[name] = value_1 ?? value_2 ?? null;
60
+ if (typeof value_3 === "string") attributes[name] = Number(value_3);
61
+ else attributes[name] = value_1 ?? value_2 ?? null;
61
62
  return "";
62
63
  }),
63
64
  attributes
@@ -11,7 +11,7 @@ import { n as RehypeTocOptions, r as rehypeToc, t as RehypeTOCItemType } from ".
11
11
  import { n as remarkCodeTab, t as RemarkCodeTabOptions } from "../remark-code-tab-C_xwrYzr.js";
12
12
  import { n as remarkSteps, t as RemarkStepsOptions } from "../remark-steps-DVaztRzR.js";
13
13
  import { n as remarkNpm, t as RemarkNpmOptions } from "../remark-npm-DWgfdohc.js";
14
- import { i as parseCodeBlockAttributes, n as CodeBlockTabsOptions, r as generateCodeBlockTabs, t as CodeBlockAttributes } from "../codeblock-utils-B5pyK6c4.js";
14
+ import { i as parseCodeBlockAttributes, n as CodeBlockTabsOptions, r as generateCodeBlockTabs, t as CodeBlockAttributes } from "../codeblock-utils-B92t2Hm-.js";
15
15
  import { a as remarkMdxFiles, r as RemarkMdxFilesOptions } from "../remark-mdx-files-D1GnBf_K.js";
16
16
  import { n as remarkMdxMermaid, t as RemarkMdxMermaidOptions } from "../remark-mdx-mermaid-B-Vm8iOc.js";
17
17
  import { n as RemarkFeedbackBlockOptions, r as remarkFeedbackBlock, t as FeedbackBlockProps } from "../remark-feedback-block-DlbKlNCS.js";
@@ -1,7 +1,7 @@
1
1
  import { remarkHeading } from "./remark-heading.js";
2
2
  import { generateCodeBlockTabs, parseCodeBlockAttributes } from "./codeblock-utils.js";
3
3
  import { remarkGfm } from "./remark-gfm.js";
4
- import { r as transformerTab } from "../rehype-code.core-Bayfuz65.js";
4
+ import { r as transformerTab } from "../rehype-code.core-CzMM-w8f.js";
5
5
  import { transformerIcon } from "./transformer-icon.js";
6
6
  import { rehypeCode, rehypeCodeDefaultOptions } from "./rehype-code.js";
7
7
  import { remarkImage } from "./remark-image.js";
@@ -1,3 +1,3 @@
1
- import { n as rehypeCodeDefaultOptions, r as transformerTab, t as createRehypeCode } from "../rehype-code.core-Bayfuz65.js";
1
+ import { n as rehypeCodeDefaultOptions, r as transformerTab, t as createRehypeCode } from "../rehype-code.core-CzMM-w8f.js";
2
2
  import { transformerIcon } from "./transformer-icon.js";
3
3
  export { createRehypeCode, rehypeCodeDefaultOptions, transformerIcon, transformerTab };
@@ -1,5 +1,5 @@
1
1
  import { defaultShikiFactory, wasmShikiFactory } from "../highlight/shiki/full.js";
2
- import { n as rehypeCodeDefaultOptions$1, r as transformerTab, t as createRehypeCode } from "../rehype-code.core-Bayfuz65.js";
2
+ import { n as rehypeCodeDefaultOptions$1, r as transformerTab, t as createRehypeCode } from "../rehype-code.core-CzMM-w8f.js";
3
3
  import { transformerIcon } from "./transformer-icon.js";
4
4
  //#region src/mdx-plugins/rehype-code.ts
5
5
  const rehypeCodeDefaultOptions = {
@@ -147,7 +147,7 @@ function remarkCodeTab(options = {}) {
147
147
  continue;
148
148
  }
149
149
  const meta = parseCodeBlockAttributes(child.meta, ["tab", "tab-group"]);
150
- if (!meta.attributes.tab) {
150
+ if (typeof meta.attributes.tab !== "string") {
151
151
  close();
152
152
  continue;
153
153
  }
@@ -155,7 +155,7 @@ function remarkCodeTab(options = {}) {
155
155
  child.meta = meta.rest;
156
156
  child.data ??= {};
157
157
  child.data.tab = meta.attributes.tab;
158
- if (meta.attributes["tab-group"]) child.data.tabGroup = meta.attributes["tab-group"];
158
+ if (typeof meta.attributes["tab-group"] === "string") child.data.tabGroup = meta.attributes["tab-group"];
159
159
  }
160
160
  close();
161
161
  });
@@ -115,7 +115,7 @@ function transformerAddLanguage(lang) {
115
115
  };
116
116
  }
117
117
  //#endregion
118
- //#region ../../node_modules/.pnpm/@shikijs+transformers@4.2.0/node_modules/@shikijs/transformers/dist/index.mjs
118
+ //#region ../../node_modules/.pnpm/@shikijs+transformers@4.3.1/node_modules/@shikijs/transformers/dist/index.mjs
119
119
  const RE_SPLIT_COMMENT = /(\s+\/\/)/;
120
120
  const RE_V1_END_COMMENT_PREFIX = /(?:\/\/|["'#]|;{1,2}|%{1,2}|--)(\s*)$/;
121
121
  const RE_V3_END_COMMENT_PREFIX = /(?:\/\/|#|;{1,2}|%{1,2}|--)(\s*)$/;
@@ -465,21 +465,30 @@ function rehypeCodeDefaultOptions() {
465
465
  transformerNotationFocus({ matchAlgorithm: "v3" })
466
466
  ],
467
467
  parseMetaString(meta) {
468
- const parsed = parseCodeBlockAttributes(meta, ["title", "tab"]);
469
- const data = parsed.attributes;
470
- parsed.rest = parseLineNumber(parsed.rest, data);
468
+ const parsed = parseCodeBlockAttributes(meta, [
469
+ "title",
470
+ "tab",
471
+ "noCopy",
472
+ "lineNumbers"
473
+ ]);
474
+ const data = {};
475
+ for (const [k, v] of Object.entries(parsed.attributes)) {
476
+ if (k === "noCopy") {
477
+ data.allowCopy = "false";
478
+ continue;
479
+ }
480
+ if (k === "lineNumbers") {
481
+ data["data-line-numbers"] = true;
482
+ if (typeof v === "number") data["data-line-numbers-start"] = v;
483
+ continue;
484
+ }
485
+ data[k] = v;
486
+ }
471
487
  data.__raw = parsed.rest;
472
488
  return data;
473
489
  }
474
490
  };
475
491
  }
476
- function parseLineNumber(str, data) {
477
- return str.replace(/lineNumbers=(\d+)|lineNumbers/, (_, ...args) => {
478
- data["data-line-numbers"] = true;
479
- if (args[0] !== void 0) data["data-line-numbers-start"] = Number(args[0]);
480
- return "";
481
- });
482
- }
483
492
  function createRehypeCode(highlighterFactory) {
484
493
  async function initTransformer(_options) {
485
494
  let highlighter;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fumadocs-core",
3
- "version": "16.10.7",
3
+ "version": "16.11.0",
4
4
  "description": "The React.js library for building a documentation website",
5
5
  "keywords": [
6
6
  "Docs",
@@ -107,14 +107,14 @@
107
107
  "github-slugger": "^2.0.0",
108
108
  "hast-util-to-estree": "^3.1.3",
109
109
  "hast-util-to-jsx-runtime": "^2.3.6",
110
- "js-yaml": "^5.1.0",
110
+ "js-yaml": "^5.2.1",
111
111
  "mdast-util-mdx": "^3.0.0",
112
112
  "mdast-util-to-markdown": "^2.1.2",
113
113
  "remark": "^15.0.1",
114
114
  "remark-gfm": "^4.0.1",
115
115
  "remark-rehype": "^11.1.2",
116
116
  "scroll-into-view-if-needed": "^3.1.0",
117
- "shiki": "^4.2.0",
117
+ "shiki": "^4.3.1",
118
118
  "tinyglobby": "^0.2.17",
119
119
  "unified": "^11.0.5",
120
120
  "unist-util-visit": "^5.1.0",
@@ -123,33 +123,33 @@
123
123
  "devDependencies": {
124
124
  "@formatjs/intl-localematcher": "^0.8.10",
125
125
  "@mdx-js/mdx": "^3.1.1",
126
- "@mixedbread/sdk": "0.76.0",
126
+ "@mixedbread/sdk": "0.77.0",
127
127
  "@orama/core": "^1.2.19",
128
128
  "@oramacloud/client": "^2.1.4",
129
- "@shikijs/transformers": "^4.2.0",
130
- "@tanstack/react-router": "1.170.16",
129
+ "@shikijs/transformers": "^4.3.1",
130
+ "@tanstack/react-router": "1.170.17",
131
131
  "@types/estree-jsx": "^1.0.5",
132
132
  "@types/hast": "^3.0.4",
133
133
  "@types/mdast": "^4.0.4",
134
134
  "@types/negotiator": "^0.6.4",
135
- "@types/node": "26.0.0",
135
+ "@types/node": "26.1.0",
136
136
  "@types/react": "^19.2.17",
137
137
  "@types/react-dom": "^19.2.3",
138
138
  "algoliasearch": "5.55.1",
139
139
  "flexsearch": "^0.8.212",
140
140
  "image-size": "^2.0.2",
141
- "lucide-react": "^1.21.0",
141
+ "lucide-react": "^1.23.0",
142
142
  "negotiator": "^1.0.0",
143
- "next": "16.2.9",
143
+ "next": "16.2.10",
144
144
  "npm-to-yarn": "^3.0.1",
145
145
  "path-to-regexp": "^8.4.2",
146
- "react-router": "^8.0.1",
146
+ "react-router": "^8.1.0",
147
147
  "remark-directive": "^4.0.0",
148
148
  "remark-mdx": "^3.1.1",
149
149
  "remove-markdown": "^0.6.4",
150
150
  "tsdown": "0.22.3",
151
151
  "typescript": "^6.0.3",
152
- "waku": "1.0.0-beta.4",
152
+ "waku": "1.0.0-beta.6",
153
153
  "zod": "4.4.3",
154
154
  "tsconfig": "0.0.0"
155
155
  },
@@ -232,7 +232,7 @@
232
232
  "inlinedDependencies": {
233
233
  "@formatjs/fast-memoize": "3.1.6",
234
234
  "@formatjs/intl-localematcher": "0.8.10",
235
- "@shikijs/transformers": "4.2.0",
235
+ "@shikijs/transformers": "4.3.1",
236
236
  "image-size": "2.0.2",
237
237
  "negotiator": "1.0.0",
238
238
  "npm-to-yarn": "3.0.1",