fumadocs-core 15.8.0 → 15.8.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.
- package/README.md +1 -1
- package/dist/breadcrumb.js +3 -3
- package/dist/{chunk-HV3YIUWE.js → chunk-2IYQ7QMS.js} +1 -12
- package/dist/chunk-CX7IQ5Z6.js +21 -0
- package/dist/chunk-DDDU7USP.js +19 -0
- package/dist/chunk-HSBNG7QC.js +42 -0
- package/dist/chunk-YVVDKJ2H.js +34 -0
- package/dist/{chunk-BDG7Y4PS.js → chunk-Z5V4JSQY.js} +0 -8
- package/dist/content/github.d.ts +34 -0
- package/dist/content/github.js +7 -0
- package/dist/{get-toc-Cr2URuiP.d.ts → content/toc.d.ts} +5 -10
- package/dist/content/toc.js +8 -0
- package/dist/i18n/middleware.js +4 -8
- package/dist/mdx-plugins/index.js +4 -4
- package/dist/negotiation/index.d.ts +19 -0
- package/dist/negotiation/index.js +11 -0
- package/dist/page-tree/index.d.ts +32 -0
- package/dist/page-tree/index.js +15 -0
- package/dist/search/server.js +5 -5
- package/dist/server/index.d.ts +10 -71
- package/dist/server/index.js +9 -64
- package/dist/source/index.d.ts +120 -92
- package/dist/source/index.js +128 -86
- package/dist/source/plugins/lucide-icons.d.ts +14 -0
- package/dist/source/plugins/lucide-icons.js +23 -0
- package/dist/toc.d.ts +7 -4
- package/package.json +32 -10
package/README.md
CHANGED
package/dist/breadcrumb.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// src/
|
|
1
|
+
// src/page-tree/utils.ts
|
|
2
2
|
function flattenTree(nodes) {
|
|
3
3
|
const out = [];
|
|
4
4
|
for (const node of nodes) {
|
|
@@ -36,16 +36,6 @@ function getPageTreeRoots(pageTree) {
|
|
|
36
36
|
if (!("type" in pageTree)) result.push(pageTree);
|
|
37
37
|
return result;
|
|
38
38
|
}
|
|
39
|
-
function separatePageTree(pageTree) {
|
|
40
|
-
return pageTree.children.flatMap((child) => {
|
|
41
|
-
if (child.type !== "folder") return [];
|
|
42
|
-
return {
|
|
43
|
-
name: child.name,
|
|
44
|
-
url: child.index?.url,
|
|
45
|
-
children: child.children
|
|
46
|
-
};
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
39
|
function getPageTreePeers(tree, url) {
|
|
50
40
|
const parent = findParentFromTree(tree, url);
|
|
51
41
|
if (!parent) return [];
|
|
@@ -102,7 +92,6 @@ export {
|
|
|
102
92
|
flattenTree,
|
|
103
93
|
findNeighbour,
|
|
104
94
|
getPageTreeRoots,
|
|
105
|
-
separatePageTree,
|
|
106
95
|
getPageTreePeers,
|
|
107
96
|
findPath
|
|
108
97
|
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import {
|
|
2
|
+
remarkHeading
|
|
3
|
+
} from "./chunk-QMATWJ5F.js";
|
|
4
|
+
|
|
5
|
+
// src/content/toc.ts
|
|
6
|
+
import { remark } from "remark";
|
|
7
|
+
function getTableOfContents(content, remarkPlugins) {
|
|
8
|
+
if (remarkPlugins) {
|
|
9
|
+
return remark().use(remarkPlugins).use(remarkHeading).process(content).then((result2) => {
|
|
10
|
+
if ("toc" in result2.data) return result2.data.toc;
|
|
11
|
+
return [];
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
const result = remark().use(remarkHeading).processSync(content);
|
|
15
|
+
if ("toc" in result.data) return result.data.toc;
|
|
16
|
+
return [];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export {
|
|
20
|
+
getTableOfContents
|
|
21
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// src/source/plugins/icon.ts
|
|
2
|
+
function iconPlugin(resolveIcon) {
|
|
3
|
+
function replaceIcon(node) {
|
|
4
|
+
if (node.icon === void 0 || typeof node.icon === "string")
|
|
5
|
+
node.icon = resolveIcon(node.icon);
|
|
6
|
+
return node;
|
|
7
|
+
}
|
|
8
|
+
return {
|
|
9
|
+
transformPageTree: {
|
|
10
|
+
file: replaceIcon,
|
|
11
|
+
folder: replaceIcon,
|
|
12
|
+
separator: replaceIcon
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export {
|
|
18
|
+
iconPlugin
|
|
19
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// src/content/github.ts
|
|
2
|
+
async function getGithubLastEdit({
|
|
3
|
+
repo,
|
|
4
|
+
token,
|
|
5
|
+
owner,
|
|
6
|
+
path,
|
|
7
|
+
sha,
|
|
8
|
+
options = {},
|
|
9
|
+
params: customParams = {}
|
|
10
|
+
}) {
|
|
11
|
+
const headers = new Headers(options.headers);
|
|
12
|
+
const params = new URLSearchParams();
|
|
13
|
+
params.set("path", path);
|
|
14
|
+
params.set("page", "1");
|
|
15
|
+
params.set("per_page", "1");
|
|
16
|
+
if (sha) params.set("sha", sha);
|
|
17
|
+
for (const [key, value] of Object.entries(customParams)) {
|
|
18
|
+
params.set(key, value);
|
|
19
|
+
}
|
|
20
|
+
if (token) {
|
|
21
|
+
headers.append("authorization", token);
|
|
22
|
+
}
|
|
23
|
+
const res = await fetch(
|
|
24
|
+
`https://api.github.com/repos/${owner}/${repo}/commits?${params.toString()}`,
|
|
25
|
+
{
|
|
26
|
+
cache: "force-cache",
|
|
27
|
+
...options,
|
|
28
|
+
headers
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
if (!res.ok)
|
|
32
|
+
throw new Error(
|
|
33
|
+
`Failed to fetch last edit time from Git ${await res.text()}`
|
|
34
|
+
);
|
|
35
|
+
const data = await res.json();
|
|
36
|
+
if (data.length === 0) return null;
|
|
37
|
+
return new Date(data[0].commit.committer.date);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export {
|
|
41
|
+
getGithubLastEdit
|
|
42
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// src/negotiation/index.ts
|
|
2
|
+
import Negotiator from "negotiator";
|
|
3
|
+
import { compile, match } from "path-to-regexp";
|
|
4
|
+
function getNegotiator(request) {
|
|
5
|
+
const headers = {};
|
|
6
|
+
request.headers.forEach((value, key) => {
|
|
7
|
+
headers[key] = value;
|
|
8
|
+
});
|
|
9
|
+
return new Negotiator({ headers });
|
|
10
|
+
}
|
|
11
|
+
function rewritePath(source, destination) {
|
|
12
|
+
const matcher = match(source, { decode: false });
|
|
13
|
+
const compiler = compile(destination, { encode: false });
|
|
14
|
+
return {
|
|
15
|
+
rewrite(pathname) {
|
|
16
|
+
const result = matcher(pathname);
|
|
17
|
+
if (!result) return false;
|
|
18
|
+
return compiler(result.params);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function isMarkdownPreferred(request, options) {
|
|
23
|
+
const {
|
|
24
|
+
markdownMediaTypes = ["text/plain", "text/markdown", "text/x-markdown"]
|
|
25
|
+
} = options ?? {};
|
|
26
|
+
const mediaTypes = getNegotiator(request).mediaTypes();
|
|
27
|
+
return markdownMediaTypes.some((type) => mediaTypes.includes(type));
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export {
|
|
31
|
+
getNegotiator,
|
|
32
|
+
rewritePath,
|
|
33
|
+
isMarkdownPreferred
|
|
34
|
+
};
|
|
@@ -30,13 +30,6 @@ function parseFilePath(path) {
|
|
|
30
30
|
}
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
|
-
function parseFolderPath(path) {
|
|
34
|
-
return {
|
|
35
|
-
dirname: dirname(path),
|
|
36
|
-
name: basename(path),
|
|
37
|
-
path
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
33
|
function splitPath(path) {
|
|
41
34
|
return path.split("/").filter((p) => p.length > 0);
|
|
42
35
|
}
|
|
@@ -69,7 +62,6 @@ export {
|
|
|
69
62
|
extname,
|
|
70
63
|
dirname,
|
|
71
64
|
parseFilePath,
|
|
72
|
-
parseFolderPath,
|
|
73
65
|
splitPath,
|
|
74
66
|
joinPath,
|
|
75
67
|
slash
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
interface GetGithubLastCommitOptions {
|
|
2
|
+
/**
|
|
3
|
+
* Repository name, like "fumadocs"
|
|
4
|
+
*/
|
|
5
|
+
repo: string;
|
|
6
|
+
/** Owner of repository */
|
|
7
|
+
owner: string;
|
|
8
|
+
/**
|
|
9
|
+
* Path to file
|
|
10
|
+
*/
|
|
11
|
+
path: string;
|
|
12
|
+
/**
|
|
13
|
+
* GitHub access token
|
|
14
|
+
*/
|
|
15
|
+
token?: string;
|
|
16
|
+
/**
|
|
17
|
+
* SHA or ref (branch or tag) name.
|
|
18
|
+
*/
|
|
19
|
+
sha?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Custom query parameters
|
|
22
|
+
*/
|
|
23
|
+
params?: Record<string, string>;
|
|
24
|
+
options?: RequestInit;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Get the last edit time of a file using GitHub API
|
|
28
|
+
*
|
|
29
|
+
* By default, this will cache the result forever.
|
|
30
|
+
* Set `options.next.revalidate` to customise this.
|
|
31
|
+
*/
|
|
32
|
+
declare function getGithubLastEdit({ repo, token, owner, path, sha, options, params: customParams, }: GetGithubLastCommitOptions): Promise<Date | null>;
|
|
33
|
+
|
|
34
|
+
export { type GetGithubLastCommitOptions, getGithubLastEdit };
|
|
@@ -1,25 +1,20 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
1
|
import { PluggableList } from 'unified';
|
|
3
2
|
import { Compatible } from 'vfile';
|
|
3
|
+
import { TOCItemType } from '../toc.js';
|
|
4
|
+
import 'react';
|
|
4
5
|
|
|
5
|
-
interface TOCItemType {
|
|
6
|
-
title: ReactNode;
|
|
7
|
-
url: string;
|
|
8
|
-
depth: number;
|
|
9
|
-
}
|
|
10
|
-
type TableOfContents = TOCItemType[];
|
|
11
6
|
/**
|
|
12
7
|
* Get Table of Contents from markdown/mdx document (using remark)
|
|
13
8
|
*
|
|
14
9
|
* @param content - Markdown content or file
|
|
15
10
|
*/
|
|
16
|
-
declare function getTableOfContents(content: Compatible):
|
|
11
|
+
declare function getTableOfContents(content: Compatible): TOCItemType[];
|
|
17
12
|
/**
|
|
18
13
|
* Get Table of Contents from markdown/mdx document (using remark)
|
|
19
14
|
*
|
|
20
15
|
* @param content - Markdown content or file
|
|
21
16
|
* @param remarkPlugins - remark plugins to be applied first
|
|
22
17
|
*/
|
|
23
|
-
declare function getTableOfContents(content: Compatible, remarkPlugins: PluggableList): Promise<
|
|
18
|
+
declare function getTableOfContents(content: Compatible, remarkPlugins: PluggableList): Promise<TOCItemType[]>;
|
|
24
19
|
|
|
25
|
-
export {
|
|
20
|
+
export { getTableOfContents };
|
package/dist/i18n/middleware.js
CHANGED
|
@@ -1,18 +1,14 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getNegotiator
|
|
3
|
+
} from "../chunk-YVVDKJ2H.js";
|
|
1
4
|
import "../chunk-JSBRDJBE.js";
|
|
2
5
|
|
|
3
6
|
// src/i18n/middleware.ts
|
|
4
7
|
import { match as matchLocale } from "@formatjs/intl-localematcher";
|
|
5
|
-
import Negotiator from "negotiator";
|
|
6
8
|
import { NextResponse } from "next/server";
|
|
7
9
|
var COOKIE = "FD_LOCALE";
|
|
8
10
|
function getLocale(request, locales, defaultLanguage) {
|
|
9
|
-
const
|
|
10
|
-
request.headers.forEach((value, key) => {
|
|
11
|
-
negotiatorHeaders[key] = value;
|
|
12
|
-
});
|
|
13
|
-
const languages = new Negotiator({ headers: negotiatorHeaders }).languages(
|
|
14
|
-
locales
|
|
15
|
-
);
|
|
11
|
+
const languages = getNegotiator(request).languages(locales);
|
|
16
12
|
return matchLocale(languages, locales, defaultLanguage);
|
|
17
13
|
}
|
|
18
14
|
var defaultFormat = (locale, path) => {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
flattenNode,
|
|
3
|
-
remarkHeading
|
|
4
|
-
} from "../chunk-QMATWJ5F.js";
|
|
5
1
|
import {
|
|
6
2
|
defaultThemes,
|
|
7
3
|
getHighlighter
|
|
8
4
|
} from "../chunk-HN2NUUD2.js";
|
|
5
|
+
import {
|
|
6
|
+
flattenNode,
|
|
7
|
+
remarkHeading
|
|
8
|
+
} from "../chunk-QMATWJ5F.js";
|
|
9
9
|
import "../chunk-JSBRDJBE.js";
|
|
10
10
|
|
|
11
11
|
// src/mdx-plugins/index.ts
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import Negotiator from 'negotiator';
|
|
2
|
+
|
|
3
|
+
declare function getNegotiator(request: Request): Negotiator;
|
|
4
|
+
/**
|
|
5
|
+
* Rewrite incoming path matching the `source` pattern into the `destination` pattern.
|
|
6
|
+
*
|
|
7
|
+
* See [`path-to-regexp`](https://github.com/pillarjs/path-to-regexp) for accepted pattern formats.
|
|
8
|
+
*
|
|
9
|
+
* @param source - the original pattern of incoming paths
|
|
10
|
+
* @param destination - the target pattern to convert into
|
|
11
|
+
*/
|
|
12
|
+
declare function rewritePath(source: string, destination: string): {
|
|
13
|
+
rewrite(pathname: string): string | false;
|
|
14
|
+
};
|
|
15
|
+
declare function isMarkdownPreferred(request: Request, options?: {
|
|
16
|
+
markdownMediaTypes?: string[];
|
|
17
|
+
}): boolean;
|
|
18
|
+
|
|
19
|
+
export { getNegotiator, isMarkdownPreferred, rewritePath };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { N as Node, I as Item, R as Root, F as Folder } from '../definitions-Q95-psoo.js';
|
|
2
|
+
export { S as Separator } from '../definitions-Q95-psoo.js';
|
|
3
|
+
import 'react';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Flatten tree to an array of page nodes
|
|
7
|
+
*/
|
|
8
|
+
declare function flattenTree(nodes: Node[]): Item[];
|
|
9
|
+
/**
|
|
10
|
+
* Get neighbours of a page, useful for implementing "previous & next" buttons
|
|
11
|
+
*/
|
|
12
|
+
declare function findNeighbour(tree: Root, url: string, options?: {
|
|
13
|
+
separateRoot?: boolean;
|
|
14
|
+
}): {
|
|
15
|
+
previous?: Item;
|
|
16
|
+
next?: Item;
|
|
17
|
+
};
|
|
18
|
+
declare function getPageTreeRoots(pageTree: Root | Folder): (Root | Folder)[];
|
|
19
|
+
/**
|
|
20
|
+
* Get other page tree nodes that lives under the same parent
|
|
21
|
+
*/
|
|
22
|
+
declare function getPageTreePeers(tree: Root, url: string): Item[];
|
|
23
|
+
/**
|
|
24
|
+
* Search the path of a node in the tree matched by the matcher.
|
|
25
|
+
*
|
|
26
|
+
* @returns The path to the target node (from starting root), or null if the page doesn't exist
|
|
27
|
+
*/
|
|
28
|
+
declare function findPath(nodes: Node[], matcher: (node: Node) => boolean, options?: {
|
|
29
|
+
includeSeparator?: boolean;
|
|
30
|
+
}): Node[] | null;
|
|
31
|
+
|
|
32
|
+
export { Folder, Item, Node, Root, findNeighbour, findPath, flattenTree, getPageTreePeers, getPageTreeRoots };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
findNeighbour,
|
|
3
|
+
findPath,
|
|
4
|
+
flattenTree,
|
|
5
|
+
getPageTreePeers,
|
|
6
|
+
getPageTreeRoots
|
|
7
|
+
} from "../chunk-2IYQ7QMS.js";
|
|
8
|
+
import "../chunk-JSBRDJBE.js";
|
|
9
|
+
export {
|
|
10
|
+
findNeighbour,
|
|
11
|
+
findPath,
|
|
12
|
+
flattenTree,
|
|
13
|
+
getPageTreePeers,
|
|
14
|
+
getPageTreeRoots
|
|
15
|
+
};
|
package/dist/search/server.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
basename,
|
|
3
|
-
extname
|
|
4
|
-
} from "../chunk-BDG7Y4PS.js";
|
|
5
1
|
import {
|
|
6
2
|
searchAdvanced,
|
|
7
3
|
searchSimple
|
|
8
4
|
} from "../chunk-XOFXGHS4.js";
|
|
9
5
|
import "../chunk-ZMWYLUDP.js";
|
|
6
|
+
import {
|
|
7
|
+
basename,
|
|
8
|
+
extname
|
|
9
|
+
} from "../chunk-Z5V4JSQY.js";
|
|
10
10
|
import {
|
|
11
11
|
createContentHighlighter
|
|
12
12
|
} from "../chunk-OTD7MV33.js";
|
|
13
13
|
import {
|
|
14
14
|
findPath
|
|
15
|
-
} from "../chunk-
|
|
15
|
+
} from "../chunk-2IYQ7QMS.js";
|
|
16
16
|
import "../chunk-JSBRDJBE.js";
|
|
17
17
|
|
|
18
18
|
// src/search/server.ts
|
package/dist/server/index.d.ts
CHANGED
|
@@ -1,80 +1,16 @@
|
|
|
1
|
-
export {
|
|
2
|
-
import { N as Node, I as Item, R as Root, F as Folder } from '../definitions-Q95-psoo.js';
|
|
3
|
-
export { d as PageTree } from '../definitions-Q95-psoo.js';
|
|
1
|
+
export { GetGithubLastCommitOptions, getGithubLastEdit } from '../content/github.js';
|
|
4
2
|
import { Metadata } from 'next';
|
|
5
3
|
import { NextRequest } from 'next/server';
|
|
6
4
|
import { LoaderOutput, LoaderConfig, InferPageType } from '../source/index.js';
|
|
5
|
+
export { getTableOfContents } from '../content/toc.js';
|
|
6
|
+
export { TOCItemType, TableOfContents } from '../toc.js';
|
|
7
7
|
export { SortedResult } from '../search/index.js';
|
|
8
|
+
export { findNeighbour, findPath, flattenTree, getPageTreePeers, getPageTreeRoots } from '../page-tree/index.js';
|
|
9
|
+
export { d as PageTree } from '../definitions-Q95-psoo.js';
|
|
10
|
+
import '../i18n/index.js';
|
|
8
11
|
import 'react';
|
|
9
12
|
import 'unified';
|
|
10
13
|
import 'vfile';
|
|
11
|
-
import '../i18n/index.js';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Flatten tree to an array of page nodes
|
|
15
|
-
*/
|
|
16
|
-
declare function flattenTree(nodes: Node[]): Item[];
|
|
17
|
-
/**
|
|
18
|
-
* Get neighbours of a page, useful for implementing "previous & next" buttons
|
|
19
|
-
*/
|
|
20
|
-
declare function findNeighbour(tree: Root, url: string, options?: {
|
|
21
|
-
separateRoot?: boolean;
|
|
22
|
-
}): {
|
|
23
|
-
previous?: Item;
|
|
24
|
-
next?: Item;
|
|
25
|
-
};
|
|
26
|
-
declare function getPageTreeRoots(pageTree: Root | Folder): (Root | Folder)[];
|
|
27
|
-
/**
|
|
28
|
-
* Separate the folder nodes of a root into multiple roots
|
|
29
|
-
*
|
|
30
|
-
* @deprecated it's useless
|
|
31
|
-
*/
|
|
32
|
-
declare function separatePageTree(pageTree: Root): Root[];
|
|
33
|
-
/**
|
|
34
|
-
* Get other page tree nodes that lives under the same parent
|
|
35
|
-
*/
|
|
36
|
-
declare function getPageTreePeers(tree: Root, url: string): Item[];
|
|
37
|
-
/**
|
|
38
|
-
* Search the path of a node in the tree matched by the matcher.
|
|
39
|
-
*
|
|
40
|
-
* @returns The path to the target node (from starting root), or null if the page doesn't exist
|
|
41
|
-
*/
|
|
42
|
-
declare function findPath(nodes: Node[], matcher: (node: Node) => boolean, options?: {
|
|
43
|
-
includeSeparator?: boolean;
|
|
44
|
-
}): Node[] | null;
|
|
45
|
-
|
|
46
|
-
interface GetGithubLastCommitOptions {
|
|
47
|
-
/**
|
|
48
|
-
* Repository name, like "fumadocs"
|
|
49
|
-
*/
|
|
50
|
-
repo: string;
|
|
51
|
-
/** Owner of repository */
|
|
52
|
-
owner: string;
|
|
53
|
-
/**
|
|
54
|
-
* Path to file
|
|
55
|
-
*/
|
|
56
|
-
path: string;
|
|
57
|
-
/**
|
|
58
|
-
* GitHub access token
|
|
59
|
-
*/
|
|
60
|
-
token?: string;
|
|
61
|
-
/**
|
|
62
|
-
* SHA or ref (branch or tag) name.
|
|
63
|
-
*/
|
|
64
|
-
sha?: string;
|
|
65
|
-
/**
|
|
66
|
-
* Custom query parameters
|
|
67
|
-
*/
|
|
68
|
-
params?: Record<string, string>;
|
|
69
|
-
options?: RequestInit;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Get the last edit time of a file using GitHub API
|
|
73
|
-
*
|
|
74
|
-
* By default, this will cache the result forever.
|
|
75
|
-
* Set `options.next.revalidate` to customise this.
|
|
76
|
-
*/
|
|
77
|
-
declare function getGithubLastEdit({ repo, token, owner, path, sha, options, params: customParams, }: GetGithubLastCommitOptions): Promise<Date | null>;
|
|
78
14
|
|
|
79
15
|
interface ImageMeta {
|
|
80
16
|
alt: string;
|
|
@@ -82,6 +18,9 @@ interface ImageMeta {
|
|
|
82
18
|
width: number;
|
|
83
19
|
height: number;
|
|
84
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* @deprecated Use the SEO features of your own React.js framework instead
|
|
23
|
+
*/
|
|
85
24
|
declare function createMetadataImage<S extends LoaderOutput<LoaderConfig>>(options: {
|
|
86
25
|
source: S;
|
|
87
26
|
/**
|
|
@@ -124,4 +63,4 @@ declare function createMetadataImage<S extends LoaderOutput<LoaderConfig>>(optio
|
|
|
124
63
|
}) => Response | Promise<Response>) => (request: NextRequest, options: any) => Response | Promise<Response>;
|
|
125
64
|
};
|
|
126
65
|
|
|
127
|
-
export {
|
|
66
|
+
export { createMetadataImage };
|
package/dist/server/index.js
CHANGED
|
@@ -1,72 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "../chunk-
|
|
2
|
+
getGithubLastEdit
|
|
3
|
+
} from "../chunk-HSBNG7QC.js";
|
|
4
|
+
import {
|
|
5
|
+
getTableOfContents
|
|
6
|
+
} from "../chunk-CX7IQ5Z6.js";
|
|
7
|
+
import "../chunk-QMATWJ5F.js";
|
|
4
8
|
import {
|
|
5
9
|
findNeighbour,
|
|
6
10
|
findPath,
|
|
7
11
|
flattenTree,
|
|
8
12
|
getPageTreePeers,
|
|
9
|
-
getPageTreeRoots
|
|
10
|
-
|
|
11
|
-
} from "../chunk-HV3YIUWE.js";
|
|
13
|
+
getPageTreeRoots
|
|
14
|
+
} from "../chunk-2IYQ7QMS.js";
|
|
12
15
|
import "../chunk-JSBRDJBE.js";
|
|
13
16
|
|
|
14
|
-
// src/server/get-toc.ts
|
|
15
|
-
import { remark } from "remark";
|
|
16
|
-
function getTableOfContents(content, remarkPlugins) {
|
|
17
|
-
if (remarkPlugins) {
|
|
18
|
-
return remark().use(remarkPlugins).use(remarkHeading).process(content).then((result2) => {
|
|
19
|
-
if ("toc" in result2.data) return result2.data.toc;
|
|
20
|
-
return [];
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
const result = remark().use(remarkHeading).processSync(content);
|
|
24
|
-
if ("toc" in result.data) return result.data.toc;
|
|
25
|
-
return [];
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// src/source/page-tree/definitions.ts
|
|
29
|
-
var definitions_exports = {};
|
|
30
|
-
|
|
31
|
-
// src/server/git-api.ts
|
|
32
|
-
async function getGithubLastEdit({
|
|
33
|
-
repo,
|
|
34
|
-
token,
|
|
35
|
-
owner,
|
|
36
|
-
path,
|
|
37
|
-
sha,
|
|
38
|
-
options = {},
|
|
39
|
-
params: customParams = {}
|
|
40
|
-
}) {
|
|
41
|
-
const headers = new Headers(options.headers);
|
|
42
|
-
const params = new URLSearchParams();
|
|
43
|
-
params.set("path", path);
|
|
44
|
-
params.set("page", "1");
|
|
45
|
-
params.set("per_page", "1");
|
|
46
|
-
if (sha) params.set("sha", sha);
|
|
47
|
-
for (const [key, value] of Object.entries(customParams)) {
|
|
48
|
-
params.set(key, value);
|
|
49
|
-
}
|
|
50
|
-
if (token) {
|
|
51
|
-
headers.append("authorization", token);
|
|
52
|
-
}
|
|
53
|
-
const res = await fetch(
|
|
54
|
-
`https://api.github.com/repos/${owner}/${repo}/commits?${params.toString()}`,
|
|
55
|
-
{
|
|
56
|
-
cache: "force-cache",
|
|
57
|
-
...options,
|
|
58
|
-
headers
|
|
59
|
-
}
|
|
60
|
-
);
|
|
61
|
-
if (!res.ok)
|
|
62
|
-
throw new Error(
|
|
63
|
-
`Failed to fetch last edit time from Git ${await res.text()}`
|
|
64
|
-
);
|
|
65
|
-
const data = await res.json();
|
|
66
|
-
if (data.length === 0) return null;
|
|
67
|
-
return new Date(data[0].commit.committer.date);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
17
|
// src/server/metadata.ts
|
|
71
18
|
function createMetadataImage(options) {
|
|
72
19
|
const { filename = "image.png", imageRoute = "/docs-og" } = options;
|
|
@@ -126,7 +73,6 @@ function createMetadataImage(options) {
|
|
|
126
73
|
};
|
|
127
74
|
}
|
|
128
75
|
export {
|
|
129
|
-
definitions_exports as PageTree,
|
|
130
76
|
createMetadataImage,
|
|
131
77
|
findNeighbour,
|
|
132
78
|
findPath,
|
|
@@ -134,6 +80,5 @@ export {
|
|
|
134
80
|
getGithubLastEdit,
|
|
135
81
|
getPageTreePeers,
|
|
136
82
|
getPageTreeRoots,
|
|
137
|
-
getTableOfContents
|
|
138
|
-
separatePageTree
|
|
83
|
+
getTableOfContents
|
|
139
84
|
};
|