@depup/nextra 4.6.1-depup.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 +56 -0
- package/changes.json +110 -0
- package/dist/client/components/banner/close-banner-button.d.ts +8 -0
- package/dist/client/components/banner/close-banner-button.js +45 -0
- package/dist/client/components/banner/index.client.d.ts +5 -0
- package/dist/client/components/banner/index.client.js +46 -0
- package/dist/client/components/banner/index.d.ts +51 -0
- package/dist/client/components/banner/index.js +93 -0
- package/dist/client/components/bleed.d.ts +63 -0
- package/dist/client/components/bleed.js +54 -0
- package/dist/client/components/button.d.ts +9 -0
- package/dist/client/components/button.js +55 -0
- package/dist/client/components/callout.d.ts +136 -0
- package/dist/client/components/callout.js +99 -0
- package/dist/client/components/cards.d.ts +104 -0
- package/dist/client/components/cards.js +132 -0
- package/dist/client/components/collapse.d.ts +12 -0
- package/dist/client/components/collapse.js +143 -0
- package/dist/client/components/file-tree/file.d.ts +9 -0
- package/dist/client/components/file-tree/file.js +43 -0
- package/dist/client/components/file-tree/folder.d.ts +12 -0
- package/dist/client/components/file-tree/folder.js +94 -0
- package/dist/client/components/file-tree/index.d.ts +57 -0
- package/dist/client/components/file-tree/index.js +12 -0
- package/dist/client/components/file-tree/tree.d.ts +5 -0
- package/dist/client/components/file-tree/tree.js +41 -0
- package/dist/client/components/head.d.ts +139 -0
- package/dist/client/components/head.js +202 -0
- package/dist/client/components/image-zoom.d.ts +6 -0
- package/dist/client/components/image-zoom.js +79 -0
- package/dist/client/components/index.d.ts +56 -0
- package/dist/client/components/index.js +42 -0
- package/dist/client/components/playground.d.ts +90 -0
- package/dist/client/components/playground.js +103 -0
- package/dist/client/components/popup/index.client.d.ts +7 -0
- package/dist/client/components/popup/index.client.js +83 -0
- package/dist/client/components/popup/index.d.ts +12 -0
- package/dist/client/components/popup/index.js +11 -0
- package/dist/client/components/search.d.ts +88 -0
- package/dist/client/components/search.js +426 -0
- package/dist/client/components/select.d.ts +19 -0
- package/dist/client/components/select.js +109 -0
- package/dist/client/components/skip-nav/index.client.d.ts +5 -0
- package/dist/client/components/skip-nav/index.client.js +45 -0
- package/dist/client/components/skip-nav/index.d.ts +6 -0
- package/dist/client/components/skip-nav/index.js +24 -0
- package/dist/client/components/steps.d.ts +64 -0
- package/dist/client/components/steps.js +74 -0
- package/dist/client/components/tabs/index.client.d.ts +21 -0
- package/dist/client/components/tabs/index.client.js +243 -0
- package/dist/client/components/tabs/index.d.ts +53 -0
- package/dist/client/components/tabs/index.js +9 -0
- package/dist/client/evaluate.d.ts +30 -0
- package/dist/client/evaluate.js +17 -0
- package/dist/client/hocs/index.d.ts +4 -0
- package/dist/client/hocs/index.js +6 -0
- package/dist/client/hocs/with-github-alert.d.ts +11 -0
- package/dist/client/hocs/with-github-alert.js +30 -0
- package/dist/client/hocs/with-icons.d.ts +6 -0
- package/dist/client/hocs/with-icons.js +76 -0
- package/dist/client/hooks/index.d.ts +4 -0
- package/dist/client/hooks/index.js +10 -0
- package/dist/client/hooks/use-copy.d.ts +9 -0
- package/dist/client/hooks/use-copy.js +77 -0
- package/dist/client/hooks/use-fs-route.d.ts +3 -0
- package/dist/client/hooks/use-fs-route.js +20 -0
- package/dist/client/hooks/use-hash.d.ts +3 -0
- package/dist/client/hooks/use-hash.js +20 -0
- package/dist/client/hooks/use-mounted.d.ts +3 -0
- package/dist/client/hooks/use-mounted.js +13 -0
- package/dist/client/icons/arrow-right.d.ts +5 -0
- package/dist/client/icons/arrow-right.js +24 -0
- package/dist/client/icons/chatgpt.d.ts +2 -0
- package/dist/client/icons/chatgpt.js +24 -0
- package/dist/client/icons/check.d.ts +2 -0
- package/dist/client/icons/check.js +24 -0
- package/dist/client/icons/claude.d.ts +2 -0
- package/dist/client/icons/claude.js +81 -0
- package/dist/client/icons/copy.d.ts +2 -0
- package/dist/client/icons/copy.js +31 -0
- package/dist/client/icons/cpp.d.ts +2 -0
- package/dist/client/icons/cpp.js +24 -0
- package/dist/client/icons/cross-circled.d.ts +2 -0
- package/dist/client/icons/cross-circled.js +24 -0
- package/dist/client/icons/csharp.d.ts +2 -0
- package/dist/client/icons/csharp.js +24 -0
- package/dist/client/icons/css.d.ts +2 -0
- package/dist/client/icons/css.js +24 -0
- package/dist/client/icons/discord.d.ts +2 -0
- package/dist/client/icons/discord.js +24 -0
- package/dist/client/icons/expand.d.ts +2 -0
- package/dist/client/icons/expand.js +31 -0
- package/dist/client/icons/file.d.ts +2 -0
- package/dist/client/icons/file.js +24 -0
- package/dist/client/icons/folder-open.d.ts +2 -0
- package/dist/client/icons/folder-open.js +24 -0
- package/dist/client/icons/folder.d.ts +2 -0
- package/dist/client/icons/folder.js +24 -0
- package/dist/client/icons/github-caution.d.ts +2 -0
- package/dist/client/icons/github-caution.js +24 -0
- package/dist/client/icons/github-important.d.ts +2 -0
- package/dist/client/icons/github-important.js +24 -0
- package/dist/client/icons/github-note.d.ts +2 -0
- package/dist/client/icons/github-note.js +24 -0
- package/dist/client/icons/github-tip.d.ts +2 -0
- package/dist/client/icons/github-tip.js +24 -0
- package/dist/client/icons/github-warning.d.ts +2 -0
- package/dist/client/icons/github-warning.js +24 -0
- package/dist/client/icons/github.d.ts +2 -0
- package/dist/client/icons/github.js +24 -0
- package/dist/client/icons/globe.d.ts +2 -0
- package/dist/client/icons/globe.js +24 -0
- package/dist/client/icons/go.d.ts +2 -0
- package/dist/client/icons/go.js +46 -0
- package/dist/client/icons/graphql.d.ts +2 -0
- package/dist/client/icons/graphql.js +56 -0
- package/dist/client/icons/index.d.ts +2 -0
- package/dist/client/icons/index.js +92 -0
- package/dist/client/icons/javascript.d.ts +2 -0
- package/dist/client/icons/javascript.js +24 -0
- package/dist/client/icons/json.d.ts +2 -0
- package/dist/client/icons/json.js +41 -0
- package/dist/client/icons/link-arrow.d.ts +2 -0
- package/dist/client/icons/link-arrow.js +31 -0
- package/dist/client/icons/link.d.ts +2 -0
- package/dist/client/icons/link.js +24 -0
- package/dist/client/icons/markdown.d.ts +2 -0
- package/dist/client/icons/markdown.js +24 -0
- package/dist/client/icons/mdx.d.ts +2 -0
- package/dist/client/icons/mdx.js +24 -0
- package/dist/client/icons/menu.d.ts +2 -0
- package/dist/client/icons/menu.js +36 -0
- package/dist/client/icons/moon.d.ts +2 -0
- package/dist/client/icons/moon.js +24 -0
- package/dist/client/icons/move.d.ts +2 -0
- package/dist/client/icons/move.js +24 -0
- package/dist/client/icons/python.d.ts +2 -0
- package/dist/client/icons/python.js +31 -0
- package/dist/client/icons/react.d.ts +2 -0
- package/dist/client/icons/react.js +38 -0
- package/dist/client/icons/rust.d.ts +2 -0
- package/dist/client/icons/rust.js +31 -0
- package/dist/client/icons/spinner.d.ts +2 -0
- package/dist/client/icons/spinner.js +31 -0
- package/dist/client/icons/sun.d.ts +2 -0
- package/dist/client/icons/sun.js +24 -0
- package/dist/client/icons/svelte.d.ts +2 -0
- package/dist/client/icons/svelte.js +31 -0
- package/dist/client/icons/terminal.d.ts +2 -0
- package/dist/client/icons/terminal.js +24 -0
- package/dist/client/icons/terraform.d.ts +2 -0
- package/dist/client/icons/terraform.js +24 -0
- package/dist/client/icons/typescript.d.ts +2 -0
- package/dist/client/icons/typescript.js +24 -0
- package/dist/client/icons/word-wrap.d.ts +2 -0
- package/dist/client/icons/word-wrap.js +24 -0
- package/dist/client/icons/x.d.ts +2 -0
- package/dist/client/icons/x.js +24 -0
- package/dist/client/mdx-components/anchor.d.ts +10 -0
- package/dist/client/mdx-components/anchor.js +109 -0
- package/dist/client/mdx-components/code.d.ts +7 -0
- package/dist/client/mdx-components/code.js +52 -0
- package/dist/client/mdx-components/details.d.ts +5 -0
- package/dist/client/mdx-components/details.js +166 -0
- package/dist/client/mdx-components/image.d.ts +28 -0
- package/dist/client/mdx-components/image.js +39 -0
- package/dist/client/mdx-components/index.d.ts +11 -0
- package/dist/client/mdx-components/index.js +16 -0
- package/dist/client/mdx-components/pre/copy-to-clipboard.d.ts +5 -0
- package/dist/client/mdx-components/pre/copy-to-clipboard.js +49 -0
- package/dist/client/mdx-components/pre/index.d.ts +16 -0
- package/dist/client/mdx-components/pre/index.js +156 -0
- package/dist/client/mdx-components/pre/toggle-word-wrap-button.d.ts +7 -0
- package/dist/client/mdx-components/pre/toggle-word-wrap-button.js +31 -0
- package/dist/client/mdx-components/summary.d.ts +5 -0
- package/dist/client/mdx-components/summary.js +80 -0
- package/dist/client/mdx-components/table.d.ts +57 -0
- package/dist/client/mdx-components/table.js +95 -0
- package/dist/client/mdx-components.d.ts +89 -0
- package/dist/client/mdx-components.js +15 -0
- package/dist/client/mdx-remote.d.ts +62 -0
- package/dist/client/mdx-remote.js +36 -0
- package/dist/client/normalize-pages.d.ts +84 -0
- package/dist/client/normalize-pages.js +232 -0
- package/dist/client/package.json +1 -0
- package/dist/client/pages.d.ts +131 -0
- package/dist/client/pages.js +39 -0
- package/dist/client/remove-links.d.ts +6 -0
- package/dist/client/remove-links.js +35 -0
- package/dist/client/setup-page.d.ts +18 -0
- package/dist/client/setup-page.js +14 -0
- package/dist/server/compile-metadata.d.ts +12 -0
- package/dist/server/compile-metadata.js +39 -0
- package/dist/server/compile.d.ts +39 -0
- package/dist/server/compile.js +158 -0
- package/dist/server/constants.d.ts +15 -0
- package/dist/server/constants.js +22 -0
- package/dist/server/fetch-filepaths-from-github.d.ts +10 -0
- package/dist/server/fetch-filepaths-from-github.js +36 -0
- package/dist/server/index.d.ts +39 -0
- package/dist/server/index.js +203 -0
- package/dist/server/loader.d.ts +18 -0
- package/dist/server/loader.js +155 -0
- package/dist/server/locales.d.ts +22 -0
- package/dist/server/locales.js +38 -0
- package/dist/server/page-map/find-meta-and-page-file-paths.d.ts +8 -0
- package/dist/server/page-map/find-meta-and-page-file-paths.js +32 -0
- package/dist/server/page-map/get.d.ts +50 -0
- package/dist/server/page-map/get.js +28 -0
- package/dist/server/page-map/index-page.d.ts +21 -0
- package/dist/server/page-map/index-page.js +57 -0
- package/dist/server/page-map/index.d.ts +26 -0
- package/dist/server/page-map/index.js +24 -0
- package/dist/server/page-map/merge-meta-with-page-map.d.ts +17 -0
- package/dist/server/page-map/merge-meta-with-page-map.js +74 -0
- package/dist/server/page-map/normalize.d.ts +17 -0
- package/dist/server/page-map/normalize.js +122 -0
- package/dist/server/page-map/placeholder.d.ts +2 -0
- package/dist/server/page-map/placeholder.js +0 -0
- package/dist/server/page-map/to-ast.d.ts +18 -0
- package/dist/server/page-map/to-ast.js +47 -0
- package/dist/server/page-map/to-js.d.ts +21 -0
- package/dist/server/page-map/to-js.js +72 -0
- package/dist/server/page-map/to-page-map.d.ts +26 -0
- package/dist/server/page-map/to-page-map.js +101 -0
- package/dist/server/recma-plugins/index.d.ts +3 -0
- package/dist/server/recma-plugins/index.js +4 -0
- package/dist/server/recma-plugins/recma-rewrite.d.ts +11 -0
- package/dist/server/recma-plugins/recma-rewrite.js +98 -0
- package/dist/server/rehype-plugins/index.d.ts +18 -0
- package/dist/server/rehype-plugins/index.js +16 -0
- package/dist/server/rehype-plugins/rehype-better-react-mathjax.d.ts +24 -0
- package/dist/server/rehype-plugins/rehype-better-react-mathjax.js +96 -0
- package/dist/server/rehype-plugins/rehype-extract-toc-content.d.ts +6 -0
- package/dist/server/rehype-plugins/rehype-extract-toc-content.js +119 -0
- package/dist/server/rehype-plugins/rehype-twoslash-popup.d.ts +6 -0
- package/dist/server/rehype-plugins/rehype-twoslash-popup.js +50 -0
- package/dist/server/rehype-plugins/rehype.d.ts +21 -0
- package/dist/server/rehype-plugins/rehype.js +84 -0
- package/dist/server/remark-plugins/index.d.ts +15 -0
- package/dist/server/remark-plugins/index.js +26 -0
- package/dist/server/remark-plugins/remark-assign-frontmatter.d.ts +10 -0
- package/dist/server/remark-plugins/remark-assign-frontmatter.js +24 -0
- package/dist/server/remark-plugins/remark-custom-heading-id.d.ts +9 -0
- package/dist/server/remark-plugins/remark-custom-heading-id.js +18 -0
- package/dist/server/remark-plugins/remark-export-only-metadata.d.ts +6 -0
- package/dist/server/remark-plugins/remark-export-only-metadata.js +18 -0
- package/dist/server/remark-plugins/remark-export-source-code.d.ts +6 -0
- package/dist/server/remark-plugins/remark-export-source-code.js +35 -0
- package/dist/server/remark-plugins/remark-headings.d.ts +12 -0
- package/dist/server/remark-plugins/remark-headings.js +133 -0
- package/dist/server/remark-plugins/remark-link-rewrite.d.ts +11 -0
- package/dist/server/remark-plugins/remark-link-rewrite.js +12 -0
- package/dist/server/remark-plugins/remark-mdx-disable-explicit-jsx.d.ts +10 -0
- package/dist/server/remark-plugins/remark-mdx-disable-explicit-jsx.js +10 -0
- package/dist/server/remark-plugins/remark-mdx-frontmatter.d.ts +6 -0
- package/dist/server/remark-plugins/remark-mdx-frontmatter.js +37 -0
- package/dist/server/remark-plugins/remark-mdx-title.d.ts +10 -0
- package/dist/server/remark-plugins/remark-mdx-title.js +53 -0
- package/dist/server/remark-plugins/remark-remove-imports.d.ts +6 -0
- package/dist/server/remark-plugins/remark-remove-imports.js +12 -0
- package/dist/server/remark-plugins/remark-static-image.d.ts +6 -0
- package/dist/server/remark-plugins/remark-static-image.js +107 -0
- package/dist/server/schemas.d.ts +352 -0
- package/dist/server/schemas.js +240 -0
- package/dist/server/tsdoc/base.d.ts +38 -0
- package/dist/server/tsdoc/base.js +284 -0
- package/dist/server/tsdoc/index.d.ts +6 -0
- package/dist/server/tsdoc/index.js +10 -0
- package/dist/server/tsdoc/tsdoc.d.ts +102 -0
- package/dist/server/tsdoc/tsdoc.js +262 -0
- package/dist/server/tsdoc/types.d.ts +64 -0
- package/dist/server/tsdoc/types.js +0 -0
- package/dist/server/tsdoc/zod-to-ts.d.ts +5 -0
- package/dist/server/tsdoc/zod-to-ts.js +107 -0
- package/dist/server/twoslash.d.ts +6 -0
- package/dist/server/twoslash.js +60 -0
- package/dist/server/utils.d.ts +12 -0
- package/dist/server/utils.js +45 -0
- package/dist/types.d.ts +128 -0
- package/dist/types.generated.d.ts +203 -0
- package/dist/types.generated.js +0 -0
- package/dist/types.js +0 -0
- package/loader.cjs +24 -0
- package/package.json +265 -0
- package/styles/cards.css +24 -0
- package/styles/code-block.css +266 -0
- package/styles/default.css +55 -0
- package/styles/react-medium-image-zoom.css +101 -0
- package/styles/scrollbar.css +14 -0
- package/styles/steps.css +22 -0
- package/styles/subheading-anchor.css +25 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
type GeneratedType = {
|
|
2
|
+
/** Type fields. */
|
|
3
|
+
entries: TypeField[];
|
|
4
|
+
};
|
|
5
|
+
type Tags = Record<string, string>;
|
|
6
|
+
type ReturnField = {
|
|
7
|
+
/** Function return type. */
|
|
8
|
+
type: string;
|
|
9
|
+
};
|
|
10
|
+
type GeneratedDefinition = {
|
|
11
|
+
/**
|
|
12
|
+
* Where type definition is located on disk.
|
|
13
|
+
*/
|
|
14
|
+
filePath?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Definition name.
|
|
17
|
+
*/
|
|
18
|
+
name: string;
|
|
19
|
+
/**
|
|
20
|
+
* Definition description.
|
|
21
|
+
*/
|
|
22
|
+
description?: string;
|
|
23
|
+
/**
|
|
24
|
+
* [TSDoc tags](https://tsdoc.org/pages/spec/tag_kinds).
|
|
25
|
+
*/
|
|
26
|
+
tags?: Tags;
|
|
27
|
+
};
|
|
28
|
+
type GeneratedFunction = {
|
|
29
|
+
signatures: {
|
|
30
|
+
/** Function parameters. */
|
|
31
|
+
params: TypeField[];
|
|
32
|
+
/** Function return. */
|
|
33
|
+
returns: TypeField[] | ReturnField;
|
|
34
|
+
}[];
|
|
35
|
+
};
|
|
36
|
+
type TypeField = {
|
|
37
|
+
/** Field name. */
|
|
38
|
+
name: string;
|
|
39
|
+
/** Field type. */
|
|
40
|
+
type: string;
|
|
41
|
+
/** Field description. */
|
|
42
|
+
description?: string;
|
|
43
|
+
/** Is field optional. */
|
|
44
|
+
optional?: boolean;
|
|
45
|
+
/** Field tags. */
|
|
46
|
+
tags?: Tags;
|
|
47
|
+
};
|
|
48
|
+
type BaseArgs = {
|
|
49
|
+
/** TypeScript source code to be processed. */
|
|
50
|
+
code: string;
|
|
51
|
+
/**
|
|
52
|
+
* The name of the exported declaration.
|
|
53
|
+
* @default "default"
|
|
54
|
+
*/
|
|
55
|
+
exportName?: string;
|
|
56
|
+
/**
|
|
57
|
+
* Whether to flatten nested objects.
|
|
58
|
+
* E.g. `{ foo: { bar: string } }` will be represented as: `{ foo.bar: string }`
|
|
59
|
+
* @default false
|
|
60
|
+
*/
|
|
61
|
+
flattened?: boolean;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export type { BaseArgs, GeneratedDefinition, GeneratedFunction, GeneratedType, ReturnField, Tags, TypeField };
|
|
File without changes
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
function generateTsFromZod(schema, indent = 2) {
|
|
3
|
+
const isZodObject = schema instanceof z.ZodObject;
|
|
4
|
+
if (!isZodObject) {
|
|
5
|
+
return generateTsFromZodType(schema, indent);
|
|
6
|
+
}
|
|
7
|
+
const objectFields = Object.entries(schema.shape).map(([key, _value]) => {
|
|
8
|
+
const value = _value;
|
|
9
|
+
const tsType = generateTsFromZodType(value, indent + 2);
|
|
10
|
+
const docComment = getDocComment(value, indent);
|
|
11
|
+
const isOptional = value instanceof z.ZodOptional || getDefaultValue(value) !== void 0;
|
|
12
|
+
return [
|
|
13
|
+
docComment,
|
|
14
|
+
" ".repeat(indent),
|
|
15
|
+
key,
|
|
16
|
+
isOptional ? "?" : "",
|
|
17
|
+
`: ${tsType}
|
|
18
|
+
`
|
|
19
|
+
].join("");
|
|
20
|
+
}).join("\n");
|
|
21
|
+
return ["{\n", objectFields, " ".repeat(indent - 2), "}"].join("");
|
|
22
|
+
}
|
|
23
|
+
function generateTsFromZodType(schema, indent) {
|
|
24
|
+
const { name } = schema.constructor;
|
|
25
|
+
const typeName = schema.meta()?.type;
|
|
26
|
+
if (typeName) return typeName;
|
|
27
|
+
if (schema instanceof z.ZodCustom) {
|
|
28
|
+
const fnName = schema.def.fn.name;
|
|
29
|
+
return fnName.startsWith("check") ? "React." + fnName.slice(5) : '"@TODO TO IMPLEMENT"';
|
|
30
|
+
}
|
|
31
|
+
switch (name) {
|
|
32
|
+
case "ZodString":
|
|
33
|
+
return "string";
|
|
34
|
+
case "ZodNumber":
|
|
35
|
+
return "number";
|
|
36
|
+
case "ZodBoolean":
|
|
37
|
+
return "boolean";
|
|
38
|
+
}
|
|
39
|
+
if (schema instanceof z.ZodPipe) {
|
|
40
|
+
return generateTsFromZodType(schema.in, indent);
|
|
41
|
+
}
|
|
42
|
+
if (schema instanceof z.ZodLiteral) {
|
|
43
|
+
return `"${[...schema.values]}"`;
|
|
44
|
+
}
|
|
45
|
+
if (schema instanceof z.ZodOptional || schema instanceof z.ZodDefault) {
|
|
46
|
+
return generateTsFromZodType(schema.def.innerType, indent);
|
|
47
|
+
}
|
|
48
|
+
if (schema instanceof z.ZodNullable) {
|
|
49
|
+
return `${generateTsFromZodType(schema.def.innerType, indent)} | null`;
|
|
50
|
+
}
|
|
51
|
+
if (schema instanceof z.ZodArray) {
|
|
52
|
+
return `${generateTsFromZodType(schema.def.element, indent)}[]`;
|
|
53
|
+
}
|
|
54
|
+
if (schema instanceof z.ZodUnion) {
|
|
55
|
+
return schema.def.options.map((opt) => {
|
|
56
|
+
const r = generateTsFromZodType(opt, indent);
|
|
57
|
+
return opt instanceof z.ZodArray ? `(${r.replace("[", ")[")}` : r;
|
|
58
|
+
}).join(" | ");
|
|
59
|
+
}
|
|
60
|
+
if (schema instanceof z.ZodObject) {
|
|
61
|
+
return generateTsFromZod(schema, indent);
|
|
62
|
+
}
|
|
63
|
+
if (schema instanceof z.ZodEnum) {
|
|
64
|
+
return schema.options.map((v) => `"${v}"`).join(" | ");
|
|
65
|
+
}
|
|
66
|
+
throw new Error(`Unknown schema type '${name}'`);
|
|
67
|
+
}
|
|
68
|
+
function getDefaultValue(schema) {
|
|
69
|
+
if (schema instanceof z.ZodDefault) {
|
|
70
|
+
return schema.def.defaultValue;
|
|
71
|
+
}
|
|
72
|
+
if (schema instanceof z.ZodPipe) {
|
|
73
|
+
return schema.in.def.defaultValue;
|
|
74
|
+
}
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
function getDocComment(schema, indent) {
|
|
78
|
+
const meta = schema.meta() ?? {};
|
|
79
|
+
const description = (
|
|
80
|
+
// @ts-expect-error -- fixme
|
|
81
|
+
meta.description || schema.def.innerType?.description
|
|
82
|
+
);
|
|
83
|
+
const defaultValue = getDefaultValue(schema);
|
|
84
|
+
const def = meta.default ?? (defaultValue === void 0 ? void 0 : JSON.stringify(defaultValue, null, 2));
|
|
85
|
+
const comments = [];
|
|
86
|
+
if (description) {
|
|
87
|
+
comments.push(description);
|
|
88
|
+
}
|
|
89
|
+
if (def !== void 0) {
|
|
90
|
+
comments.push(`@default ${def}`);
|
|
91
|
+
}
|
|
92
|
+
if (!comments.length) {
|
|
93
|
+
return "";
|
|
94
|
+
}
|
|
95
|
+
const comment = [
|
|
96
|
+
//
|
|
97
|
+
"/**",
|
|
98
|
+
...comments.flatMap(
|
|
99
|
+
(comment2) => comment2.split("\n").map((line) => ` * ${line}`)
|
|
100
|
+
),
|
|
101
|
+
" */"
|
|
102
|
+
].map((line) => `${" ".repeat(indent)}${line}`).join("\n");
|
|
103
|
+
return comment + "\n";
|
|
104
|
+
}
|
|
105
|
+
export {
|
|
106
|
+
generateTsFromZod
|
|
107
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { rendererRich } from "@shikijs/twoslash";
|
|
2
|
+
import { fromMarkdown } from "mdast-util-from-markdown";
|
|
3
|
+
import { gfmFromMarkdown } from "mdast-util-gfm";
|
|
4
|
+
import { defaultHandlers, toHast } from "mdast-util-to-hast";
|
|
5
|
+
function renderMarkdown(md) {
|
|
6
|
+
const mdast = fromMarkdown(
|
|
7
|
+
md.replaceAll(/{@link (?<link>[^}]*)}/g, "$1"),
|
|
8
|
+
// replace jsdoc links
|
|
9
|
+
{ mdastExtensions: [gfmFromMarkdown()] }
|
|
10
|
+
);
|
|
11
|
+
return toHast(mdast, {
|
|
12
|
+
handlers: {
|
|
13
|
+
code: (state, node) => {
|
|
14
|
+
if (node.lang) {
|
|
15
|
+
return this.codeToHast(node.value, {
|
|
16
|
+
...this.options,
|
|
17
|
+
transformers: [],
|
|
18
|
+
meta: {
|
|
19
|
+
__raw: node.meta ?? void 0
|
|
20
|
+
},
|
|
21
|
+
lang: node.lang
|
|
22
|
+
}).children[0];
|
|
23
|
+
}
|
|
24
|
+
return defaultHandlers.code(state, node);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}).children;
|
|
28
|
+
}
|
|
29
|
+
function renderMarkdownInline(md, context) {
|
|
30
|
+
const text = context === "tag:param" ? md.replace(/^(?<link>[\w$-]+)/, "`$1` ") : md;
|
|
31
|
+
const children = renderMarkdown.call(this, text);
|
|
32
|
+
const [firstChild] = children;
|
|
33
|
+
if (children.length === 1 && firstChild?.type === "element" && firstChild.tagName === "p")
|
|
34
|
+
return firstChild.children;
|
|
35
|
+
return children;
|
|
36
|
+
}
|
|
37
|
+
function twoslashRenderer(options) {
|
|
38
|
+
return rendererRich({
|
|
39
|
+
...options,
|
|
40
|
+
renderMarkdown,
|
|
41
|
+
renderMarkdownInline,
|
|
42
|
+
hast: {
|
|
43
|
+
hoverToken: { tagName: "Popup" },
|
|
44
|
+
hoverPopup: { tagName: "PopupPanel" },
|
|
45
|
+
hoverCompose: ({ popup, token }) => [
|
|
46
|
+
popup,
|
|
47
|
+
{
|
|
48
|
+
type: "element",
|
|
49
|
+
tagName: "PopupButton",
|
|
50
|
+
properties: {},
|
|
51
|
+
children: [token]
|
|
52
|
+
}
|
|
53
|
+
],
|
|
54
|
+
...options?.hast
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
export {
|
|
59
|
+
twoslashRenderer
|
|
60
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ArrayExpression, ObjectExpression, Expression, ExportNamedDeclaration } from 'estree';
|
|
2
|
+
|
|
3
|
+
declare const logger: {
|
|
4
|
+
info: (...args: any[]) => void;
|
|
5
|
+
warn: (...args: any[]) => void;
|
|
6
|
+
error: (...args: any[]) => void;
|
|
7
|
+
};
|
|
8
|
+
declare function pageTitleFromFilename(fileName: string): string;
|
|
9
|
+
declare function createAstExportConst(name: string, value: ArrayExpression | ObjectExpression | Expression): ExportNamedDeclaration;
|
|
10
|
+
declare function createAstObject(obj: Record<string, string | number | boolean | null | Expression>): ObjectExpression;
|
|
11
|
+
|
|
12
|
+
export { createAstExportConst, createAstObject, logger, pageTitleFromFilename };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import title from "title";
|
|
2
|
+
import { DEFAULT_PROPERTY_PROPS } from "./constants.js";
|
|
3
|
+
const logger = {
|
|
4
|
+
info: console.log.bind(null, "-", "\x1B[36minfo\x1B[0m", "[nextra]"),
|
|
5
|
+
warn: console.log.bind(null, "-", "\x1B[33mwarn\x1B[0m", "[nextra]"),
|
|
6
|
+
error: console.log.bind(null, "-", "\x1B[31merror\x1B[0m", "[nextra]")
|
|
7
|
+
};
|
|
8
|
+
function pageTitleFromFilename(fileName) {
|
|
9
|
+
return title(fileName.replaceAll(/[-_]/g, " "), {
|
|
10
|
+
special: ["SSR", "CORS", "ESLint"]
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
function createAstExportConst(name, value) {
|
|
14
|
+
return {
|
|
15
|
+
type: "ExportNamedDeclaration",
|
|
16
|
+
specifiers: [],
|
|
17
|
+
declaration: {
|
|
18
|
+
type: "VariableDeclaration",
|
|
19
|
+
kind: "const",
|
|
20
|
+
declarations: [
|
|
21
|
+
{
|
|
22
|
+
type: "VariableDeclarator",
|
|
23
|
+
id: { type: "Identifier", name },
|
|
24
|
+
init: value
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function createAstObject(obj) {
|
|
31
|
+
return {
|
|
32
|
+
type: "ObjectExpression",
|
|
33
|
+
properties: Object.entries(obj).map(([key, value]) => ({
|
|
34
|
+
...DEFAULT_PROPERTY_PROPS,
|
|
35
|
+
key: { type: "Identifier", name: key },
|
|
36
|
+
value: value && typeof value === "object" ? value : { type: "Literal", value }
|
|
37
|
+
}))
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
export {
|
|
41
|
+
createAstExportConst,
|
|
42
|
+
createAstObject,
|
|
43
|
+
logger,
|
|
44
|
+
pageTitleFromFilename
|
|
45
|
+
};
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { Heading as Heading$1 } from 'mdast';
|
|
2
|
+
import { Metadata } from 'next';
|
|
3
|
+
import { ReactElement, FC, ReactNode } from 'react';
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
import { NextraConfigSchema, MathJaxOptionsSchema, metaSchema, separatorItemSchema, menuSchema } from './server/schemas.js';
|
|
6
|
+
export { NextraConfig } from './types.generated.js';
|
|
7
|
+
import './lib/index.js';
|
|
8
|
+
import 'rehype-katex/lib/index.js';
|
|
9
|
+
import 'better-react-mathjax';
|
|
10
|
+
import 'rehype-pretty-code';
|
|
11
|
+
import '@mdx-js/mdx';
|
|
12
|
+
import 'rehype-katex';
|
|
13
|
+
|
|
14
|
+
type NextraConfigFromZod = z.infer<typeof NextraConfigSchema>;
|
|
15
|
+
interface LoaderOptions extends NextraConfigFromZod {
|
|
16
|
+
isPageImport?: boolean;
|
|
17
|
+
locales: string[];
|
|
18
|
+
contentDir?: string;
|
|
19
|
+
shouldAddLocaleToLinks?: boolean;
|
|
20
|
+
}
|
|
21
|
+
type TPageItem = {
|
|
22
|
+
name: string;
|
|
23
|
+
route: string;
|
|
24
|
+
__pagePath: string;
|
|
25
|
+
};
|
|
26
|
+
type TMetaItem = {
|
|
27
|
+
__metaPath: string;
|
|
28
|
+
};
|
|
29
|
+
interface TFolder<T = TItem> {
|
|
30
|
+
name: string;
|
|
31
|
+
route: string;
|
|
32
|
+
children: T[];
|
|
33
|
+
}
|
|
34
|
+
type TItem = TPageItem | TMetaItem | TFolder;
|
|
35
|
+
interface Folder<FileType = PageMapItem> {
|
|
36
|
+
name: string;
|
|
37
|
+
route: string;
|
|
38
|
+
children: FileType[];
|
|
39
|
+
}
|
|
40
|
+
type Import = {
|
|
41
|
+
importName: string;
|
|
42
|
+
filePath: string;
|
|
43
|
+
};
|
|
44
|
+
type MetaJsonFile = {
|
|
45
|
+
data: {
|
|
46
|
+
[fileName: string]: Meta;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
type DynamicFolder = {
|
|
50
|
+
items: DynamicMeta;
|
|
51
|
+
title?: string;
|
|
52
|
+
};
|
|
53
|
+
type DynamicMetaItem = Meta | DynamicFolder;
|
|
54
|
+
type DynamicMeta = Record<string, DynamicMetaItem>;
|
|
55
|
+
type FrontMatter = Record<string, any>;
|
|
56
|
+
type Meta = string | Record<string, any>;
|
|
57
|
+
type MdxFile<FrontMatterType = FrontMatter> = {
|
|
58
|
+
name: string;
|
|
59
|
+
route: string;
|
|
60
|
+
frontMatter?: FrontMatterType;
|
|
61
|
+
};
|
|
62
|
+
type PageMapItem = Folder | MdxFile | MetaJsonFile;
|
|
63
|
+
type Page = (MdxFile | Folder<Page>) & {
|
|
64
|
+
meta?: Exclude<Meta, string>;
|
|
65
|
+
};
|
|
66
|
+
type Heading = {
|
|
67
|
+
depth: Exclude<Heading$1['depth'], 1>;
|
|
68
|
+
value: string | ReactElement;
|
|
69
|
+
id: string;
|
|
70
|
+
};
|
|
71
|
+
type $NextraMetadata = Omit<Metadata, 'title'> & {
|
|
72
|
+
title: string;
|
|
73
|
+
filePath: string;
|
|
74
|
+
timestamp?: number;
|
|
75
|
+
readingTime?: ReadingTime;
|
|
76
|
+
};
|
|
77
|
+
type ReadingTime = {
|
|
78
|
+
text: string;
|
|
79
|
+
minutes: number;
|
|
80
|
+
time: number;
|
|
81
|
+
words: number;
|
|
82
|
+
};
|
|
83
|
+
type MathJaxOptions = z.infer<typeof MathJaxOptionsSchema>;
|
|
84
|
+
type MDXWrapper = FC<{
|
|
85
|
+
children: ReactNode;
|
|
86
|
+
bottomContent?: ReactNode;
|
|
87
|
+
} & Omit<EvaluateResult, 'default'>>;
|
|
88
|
+
type MetaRecord = Record<string, z.infer<typeof metaSchema>>;
|
|
89
|
+
type SeparatorItem = z.infer<typeof separatorItemSchema>;
|
|
90
|
+
type MenuItem = z.infer<typeof menuSchema>;
|
|
91
|
+
/**
|
|
92
|
+
* Options that can be passed to `pagefind.search()`.
|
|
93
|
+
* @remarks Copied from https://github.com/CloudCannon/pagefind/blob/2a0aa90cfb78bb8551645ac9127a1cd49cf54add/pagefind_web_js/types/index.d.ts#L72-L82
|
|
94
|
+
*/
|
|
95
|
+
type PagefindSearchOptions = {
|
|
96
|
+
/**
|
|
97
|
+
* If set, this call will load all assets but return before searching. Prefer using `pagefind.preload()` instead.
|
|
98
|
+
*/
|
|
99
|
+
preload?: boolean;
|
|
100
|
+
/**
|
|
101
|
+
* Add more verbose console logging for this search query.
|
|
102
|
+
*/
|
|
103
|
+
verbose?: boolean;
|
|
104
|
+
/**
|
|
105
|
+
* The set of filters to execute with this search. Input type is extremely flexible, see the filtering docs for details.
|
|
106
|
+
*/
|
|
107
|
+
filters?: object;
|
|
108
|
+
/**
|
|
109
|
+
* The set of sorts to use for this search, instead of relevancy.
|
|
110
|
+
*/
|
|
111
|
+
sort?: object;
|
|
112
|
+
};
|
|
113
|
+
type NextraMetadata = Metadata & {
|
|
114
|
+
asIndexPage?: boolean;
|
|
115
|
+
sidebarTitle?: string;
|
|
116
|
+
};
|
|
117
|
+
type EvaluateResult = {
|
|
118
|
+
/** The MDX component to render. */
|
|
119
|
+
default: FC<any>;
|
|
120
|
+
/** Table of contents list. */
|
|
121
|
+
toc: Heading[];
|
|
122
|
+
/** Page's front matter or `metadata` object including `title`, `description`, etc. */
|
|
123
|
+
metadata: $NextraMetadata;
|
|
124
|
+
/** Raw MDX source code */
|
|
125
|
+
sourceCode: string;
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
export type { $NextraMetadata, DynamicFolder, DynamicMeta, DynamicMetaItem, EvaluateResult, Folder, FrontMatter, Heading, Import, LoaderOptions, MDXWrapper, MathJaxOptions, MdxFile, MenuItem, Meta, MetaJsonFile, MetaRecord, NextraMetadata, Page, PageMapItem, PagefindSearchOptions, ReadingTime, SeparatorItem, TItem };
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import * as rehype_pretty_code from 'rehype-pretty-code';
|
|
2
|
+
import * as _mdx_js_mdx from '@mdx-js/mdx';
|
|
3
|
+
import * as rehype_katex from 'rehype-katex';
|
|
4
|
+
import * as better_react_mathjax from 'better-react-mathjax';
|
|
5
|
+
|
|
6
|
+
interface NextraConfig {
|
|
7
|
+
/**
|
|
8
|
+
* Enable the copy button for all code blocks by default, without needing to set `copy=true` attribute in the code block metadata.
|
|
9
|
+
* > [!TIP]
|
|
10
|
+
* >
|
|
11
|
+
* > You could still disable the button for specific blocks using `copy=false` attribute.
|
|
12
|
+
*/
|
|
13
|
+
defaultShowCopyCode?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Option to enable search functionality. When enabled, it sets the `data-pagefind-body` attribute on the `<main>` element.
|
|
16
|
+
* > [!TIP]
|
|
17
|
+
* >
|
|
18
|
+
* > When set to `codeblocks: false`, it adds the `data-pagefind-ignore="all"` attribute to all code blocks (`<pre>` elements).
|
|
19
|
+
* @default {
|
|
20
|
+
* "codeblocks": false
|
|
21
|
+
* }
|
|
22
|
+
*/
|
|
23
|
+
search?: boolean | {
|
|
24
|
+
/**
|
|
25
|
+
* Whether to index code blocks.
|
|
26
|
+
*/
|
|
27
|
+
codeblocks: boolean;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Option to automatically optimizing your static image imports with the Markdown syntax.
|
|
31
|
+
* > [!TIP]
|
|
32
|
+
* >
|
|
33
|
+
* > Example: ``.
|
|
34
|
+
* @default true
|
|
35
|
+
*/
|
|
36
|
+
staticImage?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Adds estimated reading time of `.md` and `.mdx` files using [readingTime](https://npmjs.com/package/reading-time) package.
|
|
39
|
+
* > [!TIP]
|
|
40
|
+
* >
|
|
41
|
+
* > The reading time is added to the front matter under the `readingTime` key.
|
|
42
|
+
*/
|
|
43
|
+
readingTime?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Enable LaTeX either with [KaTeX](https://katex.org) to pre-render LaTeX expressions directly in MDX or [MathJax](https://mathjax.org) to dynamically render math in the browser.
|
|
46
|
+
*/
|
|
47
|
+
latex?: boolean | {
|
|
48
|
+
renderer: "mathjax";
|
|
49
|
+
options?: {
|
|
50
|
+
/**
|
|
51
|
+
* URL for MathJax.
|
|
52
|
+
* @default "https://cdnjs.cloudflare.com"
|
|
53
|
+
*/
|
|
54
|
+
src?: string;
|
|
55
|
+
/**
|
|
56
|
+
* MathJax config. See [configuring MathJax](https://docs.mathjax.org/en/latest/options/index.html).
|
|
57
|
+
*/
|
|
58
|
+
config?: better_react_mathjax.MathJax3Config;
|
|
59
|
+
};
|
|
60
|
+
} | {
|
|
61
|
+
renderer: "katex";
|
|
62
|
+
/**
|
|
63
|
+
* KaTeX options. See https://katex.org/docs/options.html.
|
|
64
|
+
*/
|
|
65
|
+
options: rehype_katex.Options;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Enable or disable syntax highlighting.
|
|
69
|
+
* @default true
|
|
70
|
+
*/
|
|
71
|
+
codeHighlight?: boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Options specific to MDX compiling.
|
|
74
|
+
* @remarks `MdxOptions`
|
|
75
|
+
* @default {
|
|
76
|
+
* "format": "detect",
|
|
77
|
+
* "rehypePrettyCodeOptions": {}
|
|
78
|
+
* }
|
|
79
|
+
*/
|
|
80
|
+
mdxOptions?: {
|
|
81
|
+
/**
|
|
82
|
+
* List of rehype plugins.
|
|
83
|
+
*/
|
|
84
|
+
rehypePlugins?: _mdx_js_mdx.ProcessorOptions["rehypePlugins"];
|
|
85
|
+
/**
|
|
86
|
+
* List of remark plugins.
|
|
87
|
+
*/
|
|
88
|
+
remarkPlugins?: _mdx_js_mdx.ProcessorOptions["remarkPlugins"];
|
|
89
|
+
/**
|
|
90
|
+
* List of recma plugins. This is a new ecosystem, currently in beta, to transform esast trees (JavaScript).
|
|
91
|
+
*/
|
|
92
|
+
recmaPlugins?: _mdx_js_mdx.ProcessorOptions["recmaPlugins"];
|
|
93
|
+
/**
|
|
94
|
+
* Format of the file.
|
|
95
|
+
* - `'md'` means treat as markdown
|
|
96
|
+
* - `'mdx'` means treat as MDX
|
|
97
|
+
* - `'detect'` means try to detect the format based on file path.
|
|
98
|
+
* @default "detect"
|
|
99
|
+
*/
|
|
100
|
+
format?: "detect" | "mdx" | "md";
|
|
101
|
+
/**
|
|
102
|
+
* Configuration options for [Rehype Pretty Code](https://github.com/rehype-pretty/rehype-pretty-code).
|
|
103
|
+
* @remarks `RehypePrettyCodeOptions`
|
|
104
|
+
* @default {}
|
|
105
|
+
*/
|
|
106
|
+
rehypePrettyCodeOptions?: rehype_pretty_code.Options;
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* Allows you to whitelist HTML elements to be replaced with components defined in the `mdx-components.js` file.
|
|
110
|
+
* > [!TIP]
|
|
111
|
+
* >
|
|
112
|
+
* > By default, Nextra only replaces `<details>` and `<summary>` elements.
|
|
113
|
+
*/
|
|
114
|
+
whiteListTagsStyling?: string[];
|
|
115
|
+
/**
|
|
116
|
+
* Option to serve your `.md` and `.mdx` files from the `content` directory at a custom path instead of the root (`/`).
|
|
117
|
+
* @default "/"
|
|
118
|
+
*/
|
|
119
|
+
contentDirBasePath?: string;
|
|
120
|
+
/**
|
|
121
|
+
* Prefixes locale to all links in the page map information. Useful for i18n when you don't want to use Nextra's `middleware` function.
|
|
122
|
+
* @default false
|
|
123
|
+
*/
|
|
124
|
+
unstable_shouldAddLocaleToLinks?: boolean;
|
|
125
|
+
}
|
|
126
|
+
interface HeadProps {
|
|
127
|
+
/**
|
|
128
|
+
* @default {
|
|
129
|
+
* "hue": {
|
|
130
|
+
* "dark": 204,
|
|
131
|
+
* "light": 212
|
|
132
|
+
* },
|
|
133
|
+
* "saturation": {
|
|
134
|
+
* "dark": 100,
|
|
135
|
+
* "light": 100
|
|
136
|
+
* },
|
|
137
|
+
* "lightness": {
|
|
138
|
+
* "dark": 55,
|
|
139
|
+
* "light": 45
|
|
140
|
+
* }
|
|
141
|
+
* }
|
|
142
|
+
*/
|
|
143
|
+
color?: {
|
|
144
|
+
/**
|
|
145
|
+
* The hue of the primary theme color.<br/>Range: `0 - 360`
|
|
146
|
+
* @default {
|
|
147
|
+
* "dark": 204,
|
|
148
|
+
* "light": 212
|
|
149
|
+
* }
|
|
150
|
+
*/
|
|
151
|
+
hue?: number | {
|
|
152
|
+
dark: number;
|
|
153
|
+
light: number;
|
|
154
|
+
};
|
|
155
|
+
/**
|
|
156
|
+
* The saturation of the primary theme color.<br/>Range: `0 - 100`
|
|
157
|
+
* @default 100
|
|
158
|
+
*/
|
|
159
|
+
saturation?: number | {
|
|
160
|
+
dark: number;
|
|
161
|
+
light: number;
|
|
162
|
+
};
|
|
163
|
+
/**
|
|
164
|
+
* The lightness of the primary theme color.<br/>Range: `0 - 100`
|
|
165
|
+
* @default {
|
|
166
|
+
* "dark": 55,
|
|
167
|
+
* "light": 45
|
|
168
|
+
* }
|
|
169
|
+
*/
|
|
170
|
+
lightness?: number | {
|
|
171
|
+
dark: number;
|
|
172
|
+
light: number;
|
|
173
|
+
};
|
|
174
|
+
};
|
|
175
|
+
/**
|
|
176
|
+
* The glyph to use as the favicon.
|
|
177
|
+
*/
|
|
178
|
+
faviconGlyph?: string;
|
|
179
|
+
/**
|
|
180
|
+
* @default {
|
|
181
|
+
* "dark": "17,17,17",
|
|
182
|
+
* "light": "250,250,250"
|
|
183
|
+
* }
|
|
184
|
+
*/
|
|
185
|
+
backgroundColor?: {
|
|
186
|
+
/**
|
|
187
|
+
* Background color for dark theme.<br/>Format: `"rgb(RRR,GGG,BBB)" | "#RRGGBB"`
|
|
188
|
+
* @default "rgb(17,17,17)"
|
|
189
|
+
*/
|
|
190
|
+
dark?: string;
|
|
191
|
+
/**
|
|
192
|
+
* Background color for light theme.<br/>Format: `"rgb(RRR,GGG,BBB)" | "#RRGGBB"`
|
|
193
|
+
* @default "rgb(250,250,250)"
|
|
194
|
+
*/
|
|
195
|
+
light?: string;
|
|
196
|
+
};
|
|
197
|
+
/**
|
|
198
|
+
* Content of `<head>`.
|
|
199
|
+
*/
|
|
200
|
+
children?: React.ReactNode;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export type { HeadProps, NextraConfig };
|
|
File without changes
|
package/dist/types.js
ADDED
|
File without changes
|
package/loader.cjs
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/* eslint-env node */
|
|
2
|
+
// https://github.com/mdx-js/mdx/blob/061cdbf440bd8193867fcef3f5a131c08e4fe469/packages/loader/index.cjs
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Webpack loader
|
|
6
|
+
*
|
|
7
|
+
* @todo once webpack supports ESM loaders, remove this wrapper.
|
|
8
|
+
*
|
|
9
|
+
* @this {import('webpack').LoaderContext}
|
|
10
|
+
* @param {string} code
|
|
11
|
+
* @return {Promise<void>}
|
|
12
|
+
*/
|
|
13
|
+
module.exports = async function loader(code) {
|
|
14
|
+
const callback = this.async()
|
|
15
|
+
|
|
16
|
+
try {
|
|
17
|
+
// Note that `import()` caches, so this should be fast enough.
|
|
18
|
+
const { loader } = await import('./dist/server/loader.js')
|
|
19
|
+
const result = await loader.call(this, code)
|
|
20
|
+
callback(null, result)
|
|
21
|
+
} catch (error) {
|
|
22
|
+
callback(error)
|
|
23
|
+
}
|
|
24
|
+
}
|