fumadocs-core 8.0.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.
- package/LICENSE +21 -0
- package/README.md +5 -0
- package/dist/breadcrumb.d.ts +11 -0
- package/dist/breadcrumb.js +47 -0
- package/dist/chunk-2ZGUSAWB.js +12 -0
- package/dist/chunk-AFKH746E.js +40 -0
- package/dist/chunk-GT3Y35O6.js +46 -0
- package/dist/chunk-WEAGW6MQ.js +63 -0
- package/dist/dynamic-link.d.ts +14 -0
- package/dist/dynamic-link.js +33 -0
- package/dist/get-toc-YF_TdazL.d.ts +14 -0
- package/dist/link.d.ts +24 -0
- package/dist/link.js +7 -0
- package/dist/mdx-plugins/index.d.ts +89 -0
- package/dist/mdx-plugins/index.js +353 -0
- package/dist/middleware.d.ts +10 -0
- package/dist/middleware.js +43 -0
- package/dist/page-tree-izSPERQk.d.ts +37 -0
- package/dist/remark-structure-RwYPDA6M.d.ts +34 -0
- package/dist/search/client.d.ts +13 -0
- package/dist/search/client.js +52 -0
- package/dist/search/server.d.ts +51 -0
- package/dist/search/server.js +209 -0
- package/dist/search/shared.d.ts +8 -0
- package/dist/search/shared.js +0 -0
- package/dist/search-algolia/client.d.ts +28 -0
- package/dist/search-algolia/client.js +68 -0
- package/dist/search-algolia/server.d.ts +45 -0
- package/dist/search-algolia/server.js +68 -0
- package/dist/server/index.d.ts +57 -0
- package/dist/server/index.js +148 -0
- package/dist/sidebar.d.ts +19 -0
- package/dist/sidebar.js +88 -0
- package/dist/source/index.d.ts +171 -0
- package/dist/source/index.js +389 -0
- package/dist/toc.d.ts +20 -0
- package/dist/toc.js +113 -0
- package/package.json +158 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Fuma
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { R as Root } from './page-tree-izSPERQk.js';
|
|
2
|
+
import 'react';
|
|
3
|
+
|
|
4
|
+
interface BreadcrumbItem {
|
|
5
|
+
name: string;
|
|
6
|
+
url: string | null;
|
|
7
|
+
}
|
|
8
|
+
declare function useBreadcrumb(url: string, tree: Root): BreadcrumbItem[];
|
|
9
|
+
declare function getBreadcrumbItems(url: string, tree: Root): BreadcrumbItem[];
|
|
10
|
+
|
|
11
|
+
export { type BreadcrumbItem, getBreadcrumbItems, useBreadcrumb };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import "./chunk-WEAGW6MQ.js";
|
|
2
|
+
|
|
3
|
+
// src/breadcrumb.tsx
|
|
4
|
+
import { useMemo } from "react";
|
|
5
|
+
function useBreadcrumb(url, tree) {
|
|
6
|
+
return useMemo(() => getBreadcrumbItems(url, tree), [tree, url]);
|
|
7
|
+
}
|
|
8
|
+
function getBreadcrumbItems(url, tree) {
|
|
9
|
+
var _a;
|
|
10
|
+
return (_a = searchPath(tree.children, url)) != null ? _a : [];
|
|
11
|
+
}
|
|
12
|
+
function searchPath(nodes, url) {
|
|
13
|
+
var _a, _b;
|
|
14
|
+
for (const node of nodes) {
|
|
15
|
+
if (node.type === "folder") {
|
|
16
|
+
if (node.index && node.index.url === url) {
|
|
17
|
+
return [
|
|
18
|
+
{
|
|
19
|
+
name: node.index.name,
|
|
20
|
+
url: node.index.url
|
|
21
|
+
}
|
|
22
|
+
];
|
|
23
|
+
}
|
|
24
|
+
const items = searchPath(node.children, url);
|
|
25
|
+
if (items !== null) {
|
|
26
|
+
items.unshift({
|
|
27
|
+
name: node.name,
|
|
28
|
+
url: (_b = (_a = node.index) == null ? void 0 : _a.url) != null ? _b : null
|
|
29
|
+
});
|
|
30
|
+
return items;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if (node.type === "page" && node.url === url) {
|
|
34
|
+
return [
|
|
35
|
+
{
|
|
36
|
+
name: node.name,
|
|
37
|
+
url: node.url
|
|
38
|
+
}
|
|
39
|
+
];
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
export {
|
|
45
|
+
getBreadcrumbItems,
|
|
46
|
+
useBreadcrumb
|
|
47
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__objRest,
|
|
3
|
+
__spreadProps,
|
|
4
|
+
__spreadValues
|
|
5
|
+
} from "./chunk-WEAGW6MQ.js";
|
|
6
|
+
|
|
7
|
+
// src/link.tsx
|
|
8
|
+
import Original from "next/link";
|
|
9
|
+
import { forwardRef } from "react";
|
|
10
|
+
import { jsx } from "react/jsx-runtime";
|
|
11
|
+
var Link = forwardRef(
|
|
12
|
+
(_a, ref) => {
|
|
13
|
+
var _b = _a, {
|
|
14
|
+
href = "#",
|
|
15
|
+
external = !(href.startsWith("/") || href.startsWith("#") || href.startsWith("."))
|
|
16
|
+
} = _b, props = __objRest(_b, [
|
|
17
|
+
"href",
|
|
18
|
+
"external"
|
|
19
|
+
]);
|
|
20
|
+
if (external) {
|
|
21
|
+
return /* @__PURE__ */ jsx(
|
|
22
|
+
"a",
|
|
23
|
+
__spreadProps(__spreadValues({
|
|
24
|
+
ref,
|
|
25
|
+
href,
|
|
26
|
+
rel: "noreferrer noopener",
|
|
27
|
+
target: "_blank"
|
|
28
|
+
}, props), {
|
|
29
|
+
children: props.children
|
|
30
|
+
})
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
return /* @__PURE__ */ jsx(Original, __spreadValues({ ref, href }, props));
|
|
34
|
+
}
|
|
35
|
+
);
|
|
36
|
+
Link.displayName = "Link";
|
|
37
|
+
|
|
38
|
+
export {
|
|
39
|
+
Link
|
|
40
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// src/mdx-plugins/remark-heading.ts
|
|
2
|
+
import Slugger from "github-slugger";
|
|
3
|
+
|
|
4
|
+
// src/mdx-plugins/unist-visit.ts
|
|
5
|
+
import { visit as original } from "unist-util-visit";
|
|
6
|
+
var visit = original;
|
|
7
|
+
|
|
8
|
+
// src/mdx-plugins/remark-utils.ts
|
|
9
|
+
function flattenNode(node) {
|
|
10
|
+
if ("children" in node)
|
|
11
|
+
return node.children.map((child) => flattenNode(child)).join("");
|
|
12
|
+
if ("value" in node)
|
|
13
|
+
return node.value;
|
|
14
|
+
return "";
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// src/mdx-plugins/remark-heading.ts
|
|
18
|
+
var slugger = new Slugger();
|
|
19
|
+
function remarkHeading() {
|
|
20
|
+
return (node, file) => {
|
|
21
|
+
const toc = [];
|
|
22
|
+
slugger.reset();
|
|
23
|
+
visit(node, ["heading"], (heading) => {
|
|
24
|
+
var _a;
|
|
25
|
+
heading.data || (heading.data = {});
|
|
26
|
+
(_a = heading.data).hProperties || (_a.hProperties = {});
|
|
27
|
+
const text = flattenNode(heading);
|
|
28
|
+
const properties = heading.data.hProperties;
|
|
29
|
+
const id = slugger.slug(properties.id || text);
|
|
30
|
+
properties.id = id;
|
|
31
|
+
toc.push({
|
|
32
|
+
title: text,
|
|
33
|
+
url: `#${id}`,
|
|
34
|
+
depth: heading.depth
|
|
35
|
+
});
|
|
36
|
+
return "skip";
|
|
37
|
+
});
|
|
38
|
+
file.data.toc = toc;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export {
|
|
43
|
+
visit,
|
|
44
|
+
flattenNode,
|
|
45
|
+
remarkHeading
|
|
46
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
var __objRest = (source, exclude) => {
|
|
21
|
+
var target = {};
|
|
22
|
+
for (var prop in source)
|
|
23
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
+
target[prop] = source[prop];
|
|
25
|
+
if (source != null && __getOwnPropSymbols)
|
|
26
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
}
|
|
30
|
+
return target;
|
|
31
|
+
};
|
|
32
|
+
var __export = (target, all) => {
|
|
33
|
+
for (var name in all)
|
|
34
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
35
|
+
};
|
|
36
|
+
var __async = (__this, __arguments, generator) => {
|
|
37
|
+
return new Promise((resolve, reject) => {
|
|
38
|
+
var fulfilled = (value) => {
|
|
39
|
+
try {
|
|
40
|
+
step(generator.next(value));
|
|
41
|
+
} catch (e) {
|
|
42
|
+
reject(e);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
var rejected = (value) => {
|
|
46
|
+
try {
|
|
47
|
+
step(generator.throw(value));
|
|
48
|
+
} catch (e) {
|
|
49
|
+
reject(e);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
53
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export {
|
|
58
|
+
__spreadValues,
|
|
59
|
+
__spreadProps,
|
|
60
|
+
__objRest,
|
|
61
|
+
__export,
|
|
62
|
+
__async
|
|
63
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { LinkProps } from './link.js';
|
|
3
|
+
|
|
4
|
+
type DynamicLinkProps = LinkProps;
|
|
5
|
+
/**
|
|
6
|
+
* Extends the default `Link` component
|
|
7
|
+
*
|
|
8
|
+
* It supports dynamic hrefs, which means you can use `/[lang]/my-page` with `dynamicHrefs` enabled
|
|
9
|
+
*/
|
|
10
|
+
declare const DynamicLink: react.ForwardRefExoticComponent<react.AnchorHTMLAttributes<HTMLAnchorElement> & {
|
|
11
|
+
external?: boolean | undefined;
|
|
12
|
+
} & react.RefAttributes<HTMLAnchorElement>>;
|
|
13
|
+
|
|
14
|
+
export { DynamicLink, type DynamicLinkProps, DynamicLink as default };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
Link
|
|
4
|
+
} from "./chunk-AFKH746E.js";
|
|
5
|
+
import {
|
|
6
|
+
__objRest,
|
|
7
|
+
__spreadValues
|
|
8
|
+
} from "./chunk-WEAGW6MQ.js";
|
|
9
|
+
|
|
10
|
+
// src/dynamic-link.tsx
|
|
11
|
+
import { useParams } from "next/navigation";
|
|
12
|
+
import { forwardRef, useMemo } from "react";
|
|
13
|
+
import { jsx } from "react/jsx-runtime";
|
|
14
|
+
var DynamicLink = forwardRef(
|
|
15
|
+
(_a, ref) => {
|
|
16
|
+
var _b = _a, { href } = _b, props = __objRest(_b, ["href"]);
|
|
17
|
+
const params = useParams();
|
|
18
|
+
const url = useMemo(() => {
|
|
19
|
+
return href == null ? void 0 : href.replace(/\[.*\]/, (key) => {
|
|
20
|
+
const mappedKey = key.slice(1, -1);
|
|
21
|
+
const value = mappedKey in params ? params[mappedKey] : "undefined";
|
|
22
|
+
return typeof value === "string" ? value : value.join("/");
|
|
23
|
+
});
|
|
24
|
+
}, [params, href]);
|
|
25
|
+
return /* @__PURE__ */ jsx(Link, __spreadValues({ ref, href: url }, props));
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
DynamicLink.displayName = "DynamicLink";
|
|
29
|
+
var dynamic_link_default = DynamicLink;
|
|
30
|
+
export {
|
|
31
|
+
DynamicLink,
|
|
32
|
+
dynamic_link_default as default
|
|
33
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
interface TOCItemType {
|
|
2
|
+
title: string;
|
|
3
|
+
url: string;
|
|
4
|
+
depth: number;
|
|
5
|
+
}
|
|
6
|
+
type TableOfContents = TOCItemType[];
|
|
7
|
+
/**
|
|
8
|
+
* Get Table of Contents from markdown/mdx document (using remark)
|
|
9
|
+
*
|
|
10
|
+
* @param content - Markdown content
|
|
11
|
+
*/
|
|
12
|
+
declare function getTableOfContents(content: string): Promise<TableOfContents>;
|
|
13
|
+
|
|
14
|
+
export { type TableOfContents as T, type TOCItemType as a, getTableOfContents as g };
|
package/dist/link.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { AnchorHTMLAttributes } from 'react';
|
|
3
|
+
|
|
4
|
+
type LinkProps = AnchorHTMLAttributes<HTMLAnchorElement> & {
|
|
5
|
+
/**
|
|
6
|
+
* If the href is an external URL
|
|
7
|
+
*
|
|
8
|
+
* automatically determined by default
|
|
9
|
+
*/
|
|
10
|
+
external?: boolean;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Wraps `next/link` and safe to use in mdx documents
|
|
14
|
+
*/
|
|
15
|
+
declare const Link: react.ForwardRefExoticComponent<AnchorHTMLAttributes<HTMLAnchorElement> & {
|
|
16
|
+
/**
|
|
17
|
+
* If the href is an external URL
|
|
18
|
+
*
|
|
19
|
+
* automatically determined by default
|
|
20
|
+
*/
|
|
21
|
+
external?: boolean | undefined;
|
|
22
|
+
} & react.RefAttributes<HTMLAnchorElement>>;
|
|
23
|
+
|
|
24
|
+
export { type LinkProps, Link as default };
|
package/dist/link.js
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
export { Options as RemarkGfmOptions, default as remarkGfm } from 'remark-gfm';
|
|
2
|
+
import { Root } from 'hast';
|
|
3
|
+
import { RehypeShikijiOptions } from 'rehype-shikiji';
|
|
4
|
+
import { Processor, Transformer } from 'unified';
|
|
5
|
+
import { Root as Root$1 } from 'mdast';
|
|
6
|
+
export { S as StructuredData, r as remarkStructure, s as structure } from '../remark-structure-RwYPDA6M.js';
|
|
7
|
+
|
|
8
|
+
declare const rehypeCodeDefaultOptions: RehypeCodeOptions;
|
|
9
|
+
type RehypeCodeOptions = RehypeShikijiOptions & {
|
|
10
|
+
/**
|
|
11
|
+
* Filter meta string before processing
|
|
12
|
+
*/
|
|
13
|
+
filterMetaString?: (metaString: string) => string;
|
|
14
|
+
/**
|
|
15
|
+
* Default language
|
|
16
|
+
*
|
|
17
|
+
* @defaultValue plaintext
|
|
18
|
+
*/
|
|
19
|
+
defaultLang?: string;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Handle codeblocks
|
|
23
|
+
*/
|
|
24
|
+
declare function rehypeCode(this: Processor, options?: Partial<RehypeCodeOptions>): Transformer<Root, Root>;
|
|
25
|
+
|
|
26
|
+
interface RemarkImageOptions {
|
|
27
|
+
/**
|
|
28
|
+
* Preferred placeholder type
|
|
29
|
+
*
|
|
30
|
+
* @defaultValue 'blur'
|
|
31
|
+
*/
|
|
32
|
+
placeholder?: 'blur' | 'none';
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Turn images into static imports
|
|
36
|
+
*/
|
|
37
|
+
declare function remarkImage({ placeholder, }?: RemarkImageOptions): Transformer<Root$1, Root$1>;
|
|
38
|
+
|
|
39
|
+
interface RemarkDynamicContentOptions {
|
|
40
|
+
/** @defaultValue `process.cwd()` */
|
|
41
|
+
cwd?: string;
|
|
42
|
+
/** @defaultValue true */
|
|
43
|
+
trim?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Filter specific element types
|
|
46
|
+
* @defaultValue `['text','code']`
|
|
47
|
+
* */
|
|
48
|
+
visit?: string[];
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Copy content from referenced file
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* |reference:../path/to/file.ts|
|
|
55
|
+
*/
|
|
56
|
+
declare function remarkDynamicContent(options?: RemarkDynamicContentOptions): Transformer<Root$1, Root$1>;
|
|
57
|
+
|
|
58
|
+
interface HProperties {
|
|
59
|
+
id?: string;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Add heading ids and extract TOC
|
|
63
|
+
*
|
|
64
|
+
* Attach an array of `TOCItemType` to `vfile.data.toc`
|
|
65
|
+
*/
|
|
66
|
+
declare function remarkHeading(): Transformer<Root$1, Root$1>;
|
|
67
|
+
|
|
68
|
+
type PackageManager = (name: string) => {
|
|
69
|
+
packageManager: string;
|
|
70
|
+
command: string;
|
|
71
|
+
};
|
|
72
|
+
type RemarkInstallOptions = Partial<{
|
|
73
|
+
Tabs: string;
|
|
74
|
+
Tab: string;
|
|
75
|
+
packageManagers: PackageManager[];
|
|
76
|
+
}>;
|
|
77
|
+
/**
|
|
78
|
+
* It generates the following structure from a code block with `package-install` as language
|
|
79
|
+
*
|
|
80
|
+
* ```tsx
|
|
81
|
+
* <Tabs items={["pnpm", "npm", "yarn"]}>
|
|
82
|
+
* <Tab value="pnpm">...</Tab>
|
|
83
|
+
* ...
|
|
84
|
+
* </Tabs>
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
declare function remarkInstall({ Tab, Tabs, packageManagers, }?: RemarkInstallOptions): Transformer<Root$1, Root$1>;
|
|
88
|
+
|
|
89
|
+
export { type HProperties, type RehypeCodeOptions, type RemarkDynamicContentOptions, type RemarkImageOptions, type RemarkInstallOptions, rehypeCode, rehypeCodeDefaultOptions, remarkDynamicContent, remarkHeading, remarkImage, remarkInstall };
|