fumadocs-core 11.3.1 → 11.3.2

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.
@@ -1,4 +1,4 @@
1
- import { R as Root } from './page-tree-mLHMYx2B.js';
1
+ import { R as Root } from './page-tree-_omg_2NB.js';
2
2
  import 'react';
3
3
 
4
4
  interface BreadcrumbItem {
@@ -1,4 +1,4 @@
1
- import "./chunk-WEAGW6MQ.js";
1
+ import "./chunk-UWTMEZUM.js";
2
2
 
3
3
  // src/breadcrumb.tsx
4
4
  import { useMemo } from "react";
@@ -2,7 +2,7 @@ import {
2
2
  __objRest,
3
3
  __spreadProps,
4
4
  __spreadValues
5
- } from "./chunk-WEAGW6MQ.js";
5
+ } from "./chunk-UWTMEZUM.js";
6
6
 
7
7
  // src/link.tsx
8
8
  import Original from "next/link";
@@ -13,8 +13,7 @@ function remarkHeading({
13
13
  visit(root, "heading", (heading) => {
14
14
  var _a;
15
15
  const node = heading.children.at(-1);
16
- if (!node || node.type !== "text")
17
- return;
16
+ if (!node || node.type !== "text") return;
18
17
  heading.data || (heading.data = {});
19
18
  (_a = heading.data).hProperties || (_a.hProperties = {});
20
19
  let id = heading.data.hProperties.id;
@@ -1,11 +1,11 @@
1
1
  "use client";
2
2
  import {
3
3
  Link
4
- } from "./chunk-AFKH746E.js";
4
+ } from "./chunk-2BP57A6C.js";
5
5
  import {
6
6
  __objRest,
7
7
  __spreadValues
8
- } from "./chunk-WEAGW6MQ.js";
8
+ } from "./chunk-UWTMEZUM.js";
9
9
 
10
10
  // src/dynamic-link.tsx
11
11
  import { useParams } from "next/navigation";
package/dist/link.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  Link
3
- } from "./chunk-AFKH746E.js";
4
- import "./chunk-WEAGW6MQ.js";
3
+ } from "./chunk-2BP57A6C.js";
4
+ import "./chunk-UWTMEZUM.js";
5
5
  export {
6
6
  Link as default
7
7
  };
@@ -4,7 +4,7 @@ import { RehypeShikiOptions } from '@shikijs/rehype';
4
4
  import { Processor, Transformer } from 'unified';
5
5
  import { ShikiTransformer } from 'shiki';
6
6
  import { Root as Root$1, Heading } from 'mdast';
7
- export { a as StructureOptions, S as StructuredData, r as remarkStructure, s as structure } from '../remark-structure-Os9Vuaua.js';
7
+ export { a as StructureOptions, S as StructuredData, r as remarkStructure, s as structure } from '../remark-structure-Dj8oa5Ba.js';
8
8
 
9
9
  interface CodeBlockIcon {
10
10
  viewBox: string;
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  remarkHeading
3
- } from "../chunk-5BST7EWT.js";
3
+ } from "../chunk-EWRPHFJQ.js";
4
4
  import {
5
5
  slash
6
6
  } from "../chunk-UWEEHUJV.js";
7
7
  import {
8
8
  __async,
9
9
  __spreadValues
10
- } from "../chunk-WEAGW6MQ.js";
10
+ } from "../chunk-UWTMEZUM.js";
11
11
 
12
12
  // src/mdx-plugins/index.ts
13
13
  import {
@@ -161,11 +161,9 @@ function transformerIcon(options = {}) {
161
161
  name: "rehype-code:icon",
162
162
  root(root) {
163
163
  const lang = this.options.lang;
164
- if (!lang)
165
- return;
164
+ if (!lang) return;
166
165
  const pre = root.children[0];
167
- if (pre.type !== "element")
168
- return;
166
+ if (pre.type !== "element") return;
169
167
  const iconName = lang in shortcuts ? shortcuts[lang] : lang;
170
168
  const icon = iconName in icons ? icons[iconName] : icons.default;
171
169
  const tree = toEstree(pre, {
@@ -324,6 +322,14 @@ function rehypeCode(options = {}) {
324
322
  meta.__raw = codeOptions.filterMetaString((_a = meta.__raw) != null ? _a : "");
325
323
  }
326
324
  return code.replace(/\n$/, "");
325
+ },
326
+ line(hast) {
327
+ if (hast.children.length === 0) {
328
+ hast.children.push({
329
+ type: "text",
330
+ value: " "
331
+ });
332
+ }
327
333
  }
328
334
  },
329
335
  ...codeOptions.transformers
@@ -336,7 +342,7 @@ function rehypeCode(options = {}) {
336
342
  }
337
343
  const prefix = "language-";
338
344
  const transformer = rehypeShiki.call(this, codeOptions);
339
- return (root, vfile) => __async(this, null, function* () {
345
+ return (root, file) => __async(this, null, function* () {
340
346
  visit(root, ["pre"], (element) => {
341
347
  var _a;
342
348
  const head = element.children[0];
@@ -344,8 +350,7 @@ function rehypeCode(options = {}) {
344
350
  return;
345
351
  (_a = head.properties).className || (_a.className = []);
346
352
  const classes = head.properties.className;
347
- if (!Array.isArray(classes))
348
- return;
353
+ if (!Array.isArray(classes)) return;
349
354
  const hasLanguage = classes.some(
350
355
  (d) => typeof d === "string" && d.startsWith(prefix)
351
356
  );
@@ -353,7 +358,7 @@ function rehypeCode(options = {}) {
353
358
  classes.push(`${prefix}${codeOptions.defaultLang}`);
354
359
  });
355
360
  if (transformer)
356
- yield transformer.call(this, root, vfile, () => {
361
+ yield transformer.call(this, root, file, () => {
357
362
  });
358
363
  });
359
364
  }
@@ -460,8 +465,7 @@ import { visit as visit3 } from "unist-util-visit";
460
465
  function flattenNode(node) {
461
466
  if ("children" in node)
462
467
  return node.children.map((child) => flattenNode(child)).join("");
463
- if ("value" in node)
464
- return node.value;
468
+ if ("value" in node) return node.value;
465
469
  return "";
466
470
  }
467
471
 
@@ -476,8 +480,7 @@ function remarkStructure({
476
480
  let lastHeading = "";
477
481
  visit3(node, types, (element) => {
478
482
  var _a, _b;
479
- if (element.type === "root")
480
- return;
483
+ if (element.type === "root") return;
481
484
  const content = flattenNode(element).trim();
482
485
  if (element.type === "heading") {
483
486
  element.data || (element.data = {});
@@ -1,4 +1,4 @@
1
- import "./chunk-WEAGW6MQ.js";
1
+ import "./chunk-UWTMEZUM.js";
2
2
 
3
3
  // src/middleware.ts
4
4
  import { match as matchLocale } from "@formatjs/intl-localematcher";
@@ -1,23 +1,19 @@
1
1
  import {
2
2
  __async
3
- } from "../chunk-WEAGW6MQ.js";
3
+ } from "../chunk-UWTMEZUM.js";
4
4
 
5
5
  // src/search/client.ts
6
6
  import { useEffect, useState } from "react";
7
7
  import useSWR from "swr";
8
8
  function fetchDocs(api, query, locale, tag) {
9
9
  return __async(this, null, function* () {
10
- if (query.length === 0)
11
- return "empty";
10
+ if (query.length === 0) return "empty";
12
11
  const params = new URLSearchParams();
13
12
  params.set("query", query);
14
- if (locale)
15
- params.set("locale", locale);
16
- if (tag)
17
- params.set("tag", tag);
13
+ if (locale) params.set("locale", locale);
14
+ if (tag) params.set("tag", tag);
18
15
  const res = yield fetch(`${api}?${params.toString()}`);
19
- if (!res.ok)
20
- throw new Error(yield res.text());
16
+ if (!res.ok) throw new Error(yield res.text());
21
17
  return yield res.json();
22
18
  });
23
19
  }
@@ -1,5 +1,5 @@
1
1
  import { NextRequest, NextResponse } from 'next/server';
2
- import { S as StructuredData } from '../remark-structure-Os9Vuaua.js';
2
+ import { S as StructuredData } from '../remark-structure-Dj8oa5Ba.js';
3
3
  import { SortedResult } from './shared.js';
4
4
  import 'mdast';
5
5
  import 'unified';
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  __spreadProps,
3
3
  __spreadValues
4
- } from "../chunk-WEAGW6MQ.js";
4
+ } from "../chunk-UWTMEZUM.js";
5
5
 
6
6
  // src/search/server.ts
7
7
  import { Document } from "flexsearch";
@@ -12,8 +12,7 @@ function create(search) {
12
12
  GET(request) {
13
13
  var _a, _b;
14
14
  const query = request.nextUrl.searchParams.get("query");
15
- if (!query)
16
- return NextResponse.json([]);
15
+ if (!query) return NextResponse.json([]);
17
16
  return NextResponse.json(
18
17
  search(query, {
19
18
  tag: (_a = request.nextUrl.searchParams.get("tag")) != null ? _a : void 0,
@@ -45,8 +44,7 @@ function createI18nSearchAPI(type, options) {
45
44
  return create((query, searchOptions) => {
46
45
  if (searchOptions == null ? void 0 : searchOptions.locale) {
47
46
  const handler = map.get(searchOptions.locale);
48
- if (handler)
49
- return handler.search(query, searchOptions);
47
+ if (handler) return handler.search(query, searchOptions);
50
48
  }
51
49
  return [];
52
50
  });
@@ -95,8 +93,7 @@ function initSearchAPI({ indexes, language }) {
95
93
  enrich: true,
96
94
  suggest: true
97
95
  });
98
- if (results.length === 0)
99
- return [];
96
+ if (results.length === 0) return [];
100
97
  return results[0].result.map((page) => ({
101
98
  type: "page",
102
99
  content: page.doc.title,
@@ -190,8 +187,7 @@ function initSearchAPIAdvanced({
190
187
  }
191
188
  for (const [id, items] of map.entries()) {
192
189
  const page = index.get(id);
193
- if (!page)
194
- continue;
190
+ if (!page) continue;
195
191
  sortedResult.push({
196
192
  id: page.id,
197
193
  content: page.content,
@@ -4,7 +4,7 @@ import { SWRResponse } from 'swr';
4
4
  import { SortedResult } from '../search/shared.js';
5
5
  import { BaseIndex } from './server.js';
6
6
  import 'algoliasearch';
7
- import '../remark-structure-Os9Vuaua.js';
7
+ import '../remark-structure-Dj8oa5Ba.js';
8
8
  import 'mdast';
9
9
  import 'unified';
10
10
 
@@ -2,7 +2,7 @@ import {
2
2
  __async,
3
3
  __objRest,
4
4
  __spreadValues
5
- } from "../chunk-WEAGW6MQ.js";
5
+ } from "../chunk-UWTMEZUM.js";
6
6
 
7
7
  // src/search-algolia/client.ts
8
8
  import { useState } from "react";
@@ -51,8 +51,7 @@ function useAlgoliaSearch(index, _a = {}) {
51
51
  const query = useSWR(
52
52
  ["algolia-search", search, allowEmpty, options],
53
53
  () => __async(this, null, function* () {
54
- if (allowEmpty && search.length === 0)
55
- return "empty";
54
+ if (allowEmpty && search.length === 0) return "empty";
56
55
  return searchDocs(index, search, options);
57
56
  }),
58
57
  {
@@ -1,5 +1,5 @@
1
1
  import { SearchClient, SearchIndex } from 'algoliasearch';
2
- import { S as StructuredData } from '../remark-structure-Os9Vuaua.js';
2
+ import { S as StructuredData } from '../remark-structure-Dj8oa5Ba.js';
3
3
  import 'mdast';
4
4
  import 'unified';
5
5
 
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  __async,
3
3
  __spreadValues
4
- } from "../chunk-WEAGW6MQ.js";
4
+ } from "../chunk-UWTMEZUM.js";
5
5
 
6
6
  // src/search-algolia/server.ts
7
7
  import { randomUUID } from "crypto";
@@ -1,6 +1,6 @@
1
- export { a as TOCItemType, T as TableOfContents, g as getTableOfContents } from '../get-toc-YF_TdazL.js';
2
- import { N as Node, I as Item, R as Root } from '../page-tree-mLHMYx2B.js';
3
- export { p as PageTree } from '../page-tree-mLHMYx2B.js';
1
+ export { a as TOCItemType, T as TableOfContents, g as getTableOfContents } from '../get-toc-B-AMfFKT.js';
2
+ import { N as Node, I as Item, R as Root } from '../page-tree-_omg_2NB.js';
3
+ export { p as PageTree } from '../page-tree-_omg_2NB.js';
4
4
  import 'react';
5
5
 
6
6
  /**
@@ -1,17 +1,16 @@
1
1
  import {
2
2
  remarkHeading
3
- } from "../chunk-5BST7EWT.js";
3
+ } from "../chunk-EWRPHFJQ.js";
4
4
  import {
5
5
  __async
6
- } from "../chunk-WEAGW6MQ.js";
6
+ } from "../chunk-UWTMEZUM.js";
7
7
 
8
8
  // src/server/get-toc.ts
9
9
  import { remark } from "remark";
10
10
  function getTableOfContents(content) {
11
11
  return __async(this, null, function* () {
12
12
  const result = yield remark().use(remarkHeading).process(content);
13
- if ("toc" in result.data)
14
- return result.data.toc;
13
+ if ("toc" in result.data) return result.data.toc;
15
14
  return [];
16
15
  });
17
16
  }
@@ -19,12 +18,10 @@ function getTableOfContents(content) {
19
18
  // src/server/page-tree-utils.ts
20
19
  function flattenTree(tree) {
21
20
  return tree.flatMap((node) => {
22
- if (node.type === "separator")
23
- return [];
21
+ if (node.type === "separator") return [];
24
22
  if (node.type === "folder") {
25
23
  const child = flattenTree(node.children);
26
- if (node.index)
27
- return [node.index, ...child];
24
+ if (node.index) return [node.index, ...child];
28
25
  return child;
29
26
  }
30
27
  return [node];
@@ -45,8 +42,7 @@ function findNeighbour(tree, url) {
45
42
  function separatePageTree(pageTree) {
46
43
  return pageTree.children.flatMap((child) => {
47
44
  var _a;
48
- if (child.type !== "folder")
49
- return [];
45
+ if (child.type !== "folder") return [];
50
46
  return {
51
47
  name: child.name,
52
48
  url: (_a = child.index) == null ? void 0 : _a.url,
@@ -88,8 +84,7 @@ function getGithubLastEdit(_0) {
88
84
  `Failed to fetch last edit time from Git ${yield res.text()}`
89
85
  );
90
86
  const data = yield res.json();
91
- if (data.length === 0)
92
- return null;
87
+ if (data.length === 0) return null;
93
88
  return new Date(data[0].commit.committer.date);
94
89
  });
95
90
  }
package/dist/sidebar.js CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  __objRest,
3
3
  __spreadProps,
4
4
  __spreadValues
5
- } from "./chunk-WEAGW6MQ.js";
5
+ } from "./chunk-UWTMEZUM.js";
6
6
 
7
7
  // src/sidebar.tsx
8
8
  import { usePathname } from "next/navigation";
@@ -18,8 +18,7 @@ import { jsx } from "react/jsx-runtime";
18
18
  var SidebarContext = createContext(void 0);
19
19
  function useSidebarContext() {
20
20
  const ctx = useContext(SidebarContext);
21
- if (!ctx)
22
- throw new Error("Missing sidebar provider");
21
+ if (!ctx) throw new Error("Missing sidebar provider");
23
22
  return ctx;
24
23
  }
25
24
  function SidebarProvider(props) {
@@ -67,8 +66,7 @@ function SidebarList(_a) {
67
66
  const [open] = useSidebarContext();
68
67
  const [isBlocking, setIsBlocking] = useState(false);
69
68
  useEffect(() => {
70
- if (!blockScrollingWidth)
71
- return;
69
+ if (!blockScrollingWidth) return;
72
70
  const mediaQueryList = window.matchMedia(
73
71
  `(min-width: ${blockScrollingWidth.toString()}px)`
74
72
  );
@@ -1,5 +1,5 @@
1
1
  import { ReactElement } from 'react';
2
- import { R as Root } from '../page-tree-mLHMYx2B.js';
2
+ import { R as Root } from '../page-tree-_omg_2NB.js';
3
3
 
4
4
  interface FileInfo {
5
5
  locale?: string;
@@ -5,7 +5,7 @@ import {
5
5
  __export,
6
6
  __spreadProps,
7
7
  __spreadValues
8
- } from "../chunk-WEAGW6MQ.js";
8
+ } from "../chunk-UWTMEZUM.js";
9
9
 
10
10
  // src/source/path.ts
11
11
  import { parse } from "path";
@@ -73,8 +73,7 @@ function buildAll(nodes, ctx, skipIndex) {
73
73
  if ("data" in node && node.format === "page" && !node.file.locale) {
74
74
  const treeNode = buildFileNode(node, ctx);
75
75
  if (node.file.name === "index") {
76
- if (!skipIndex)
77
- output.unshift(treeNode);
76
+ if (!skipIndex) output.unshift(treeNode);
78
77
  continue;
79
78
  }
80
79
  output.push(treeNode);
@@ -87,8 +86,7 @@ function buildAll(nodes, ctx, skipIndex) {
87
86
  }
88
87
  function resolveFolderItem(folder, item, ctx, addedNodePaths) {
89
88
  var _a, _b, _c;
90
- if (item === rest)
91
- return "...";
89
+ if (item === rest) return "...";
92
90
  const separateResult = separator.exec(item);
93
91
  if (separateResult == null ? void 0 : separateResult.groups) {
94
92
  return [
@@ -117,8 +115,7 @@ function resolveFolderItem(folder, item, ctx, addedNodePaths) {
117
115
  (_b = (_a = extractResult == null ? void 0 : extractResult.groups) == null ? void 0 : _a.name) != null ? _b : item
118
116
  );
119
117
  const itemNode = (_c = ctx.storage.readDir(path)) != null ? _c : ctx.storage.read(path, "page");
120
- if (!itemNode)
121
- return [];
118
+ if (!itemNode) return [];
122
119
  addedNodePaths.add(itemNode.file.path);
123
120
  if ("children" in itemNode) {
124
121
  const node = buildFolderNode(itemNode, false, ctx);
@@ -209,8 +206,7 @@ function createPageTreeBuilder(options) {
209
206
  };
210
207
  }
211
208
  function findLocalizedFile(path, format, ctx) {
212
- if (!ctx.lang)
213
- return;
209
+ if (!ctx.lang) return;
214
210
  return ctx.storage.read(`${path}.${ctx.lang}`, format);
215
211
  }
216
212
  function pathToName(path) {
@@ -219,8 +215,7 @@ function pathToName(path) {
219
215
  function removeUndefined(value) {
220
216
  const obj = value;
221
217
  Object.keys(obj).forEach((key) => {
222
- if (obj[key] === void 0)
223
- delete obj[key];
218
+ if (obj[key] === void 0) delete obj[key];
224
219
  });
225
220
  return value;
226
221
  }
@@ -272,8 +267,7 @@ var Storage = class {
272
267
  const segments = splitPath(path);
273
268
  for (let i = 0; i < segments.length; i++) {
274
269
  const segment = segments.slice(0, i + 1).join("/");
275
- if (this.folders.has(segment))
276
- continue;
270
+ if (this.folders.has(segment)) continue;
277
271
  const folder = {
278
272
  file: parseFolderPath(segment),
279
273
  children: []
@@ -292,8 +286,7 @@ function loadFiles(files, options) {
292
286
  const rootDir = normalizePath((_a = options.rootDir) != null ? _a : "");
293
287
  for (const file of files) {
294
288
  const normalizedPath = normalizePath(file.path);
295
- if (!normalizedPath.startsWith(rootDir))
296
- continue;
289
+ if (!normalizedPath.startsWith(rootDir)) continue;
297
290
  const relativePath = normalizedPath.slice(rootDir.length);
298
291
  if (file.type === "page") {
299
292
  const parsedPath = parseFilePath(relativePath);
@@ -325,8 +318,7 @@ function buildPageMap(storage, languages, getUrl) {
325
318
  const defaultMap = /* @__PURE__ */ new Map();
326
319
  map.set("", defaultMap);
327
320
  for (const file of storage.list()) {
328
- if (file.format !== "page" || file.file.locale)
329
- continue;
321
+ if (file.format !== "page" || file.file.locale) continue;
330
322
  const page = fileToPage(file, getUrl);
331
323
  defaultMap.set(page.slugs.join("/"), page);
332
324
  for (const lang of languages) {
package/dist/toc.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react from 'react';
2
2
  import { HTMLAttributes, RefObject, ReactNode, AnchorHTMLAttributes } from 'react';
3
- import { T as TableOfContents } from './get-toc-YF_TdazL.js';
3
+ import { T as TableOfContents } from './get-toc-B-AMfFKT.js';
4
4
 
5
5
  declare const useActiveAnchor: (url: string) => boolean;
6
6
  interface TOCProviderProps extends HTMLAttributes<HTMLDivElement> {
package/dist/toc.js CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  __objRest,
3
3
  __spreadProps,
4
4
  __spreadValues
5
- } from "./chunk-WEAGW6MQ.js";
5
+ } from "./chunk-UWTMEZUM.js";
6
6
 
7
7
  // src/toc.tsx
8
8
  import {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fumadocs-core",
3
- "version": "11.3.1",
3
+ "version": "11.3.2",
4
4
  "description": "The library for building a documentation website in Next.js",
5
5
  "keywords": [
6
6
  "NextJs",
File without changes