@rasenganjs/mdx 1.2.0-beta.7 → 1.2.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/CHANGELOG.md +4 -0
- package/dist/chunk-U2MZHTHK.js +89 -0
- package/dist/index.cjs +922 -0
- package/dist/index.d.cts +150 -0
- package/dist/index.d.ts +150 -0
- package/dist/index.js +798 -0
- package/dist/plugin.cjs +289 -0
- package/dist/plugin.d.cts +20 -0
- package/dist/plugin.d.ts +20 -0
- package/dist/plugin.js +174 -0
- package/package.json +15 -15
- package/tsup.config.ts +11 -0
- package/types/client.d.ts +1 -1
- package/lib/components/codeblock.d.ts +0 -15
- package/lib/components/codeblock.js +0 -62
- package/lib/components/codeblock.js.map +0 -1
- package/lib/components/codeblock2.d.ts +0 -14
- package/lib/components/codeblock2.js +0 -47
- package/lib/components/codeblock2.js.map +0 -1
- package/lib/components/heading.d.ts +0 -2
- package/lib/components/heading.js +0 -27
- package/lib/components/heading.js.map +0 -1
- package/lib/components/index.d.ts +0 -5
- package/lib/components/index.js +0 -8
- package/lib/components/index.js.map +0 -1
- package/lib/components/markdown.d.ts +0 -7
- package/lib/components/markdown.js +0 -28
- package/lib/components/markdown.js.map +0 -1
- package/lib/components/renderer.d.ts +0 -12
- package/lib/components/renderer.js +0 -45
- package/lib/components/renderer.js.map +0 -1
- package/lib/components/table.d.ts +0 -3
- package/lib/components/table.js +0 -5
- package/lib/components/table.js.map +0 -1
- package/lib/components/toc.d.ts +0 -7
- package/lib/components/toc.js +0 -26
- package/lib/components/toc.js.map +0 -1
- package/lib/hooks/use-toc-observer.d.ts +0 -8
- package/lib/hooks/use-toc-observer.js +0 -60
- package/lib/hooks/use-toc-observer.js.map +0 -1
- package/lib/index.d.ts +0 -13
- package/lib/index.js +0 -16
- package/lib/index.js.map +0 -1
- package/lib/styles/rasengan-mdx.min.css +0 -1
- package/lib/types/index.d.ts +0 -67
- package/lib/types/index.js +0 -2
- package/lib/types/index.js.map +0 -1
- package/lib/utils/create-filter.d.ts +0 -8
- package/lib/utils/create-filter.js +0 -23
- package/lib/utils/create-filter.js.map +0 -1
- package/lib/utils/create-heading.d.ts +0 -4
- package/lib/utils/create-heading.js +0 -19
- package/lib/utils/create-heading.js.map +0 -1
- package/lib/utils/define-mdx-config.d.ts +0 -2
- package/lib/utils/define-mdx-config.js +0 -4
- package/lib/utils/define-mdx-config.js.map +0 -1
- package/lib/utils/extract-toc.d.ts +0 -23
- package/lib/utils/extract-toc.js +0 -113
- package/lib/utils/extract-toc.js.map +0 -1
- package/lib/utils/generate-navigation.d.ts +0 -0
- package/lib/utils/generate-navigation.js +0 -75
- package/lib/utils/generate-navigation.js.map +0 -1
- package/lib/utils/index.d.ts +0 -15
- package/lib/utils/index.js +0 -4
- package/lib/utils/index.js.map +0 -1
- package/lib/utils/mark-to-html.d.ts +0 -1
- package/lib/utils/mark-to-html.js +0 -15
- package/lib/utils/mark-to-html.js.map +0 -1
- package/lib/utils/plugin.d.ts +0 -26
- package/lib/utils/plugin.js +0 -149
- package/lib/utils/plugin.js.map +0 -1
- package/lib/utils/polyfill.d.ts +0 -10
- package/lib/utils/polyfill.js +0 -15
- package/lib/utils/polyfill.js.map +0 -1
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { Metadata } from 'rasengan';
|
|
2
|
+
import React$1 from 'react';
|
|
3
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A React functional component that represents an MDX page.
|
|
7
|
+
*
|
|
8
|
+
* The `MDXPageComponent` type extends the `React.FC<ReactComponentProps>` type, which means it is a React functional component that accepts the standard props for a React component.
|
|
9
|
+
*
|
|
10
|
+
* The `MDXPageComponent` type also has an optional `metadata` property of type `Metadata`, which can be used to store metadata about the page.
|
|
11
|
+
*/
|
|
12
|
+
type MDXPageComponent = React$1.FC<any> & {
|
|
13
|
+
metadata?: {
|
|
14
|
+
path: string;
|
|
15
|
+
metadata: Metadata;
|
|
16
|
+
};
|
|
17
|
+
toc?: Array<TOCItem>;
|
|
18
|
+
};
|
|
19
|
+
type TOCItem = {
|
|
20
|
+
title: string;
|
|
21
|
+
anchor: {
|
|
22
|
+
id: string;
|
|
23
|
+
text: React$1.ReactNode;
|
|
24
|
+
};
|
|
25
|
+
level: 2 | 3;
|
|
26
|
+
children: Array<Omit<TOCItem, 'children'>>;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* A React functional component that represents a simple block element.
|
|
30
|
+
*/
|
|
31
|
+
type ComponentWithTextChildrenProps = {
|
|
32
|
+
children: React$1.ReactNode;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* A React functional component that represents a simple block element.
|
|
36
|
+
*/
|
|
37
|
+
type MDXRendererProps = {
|
|
38
|
+
children: MDXPageComponent;
|
|
39
|
+
className?: string;
|
|
40
|
+
config?: MDXConfigProps;
|
|
41
|
+
toc?: Array<TOCItem>;
|
|
42
|
+
raw?: string;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* A React functional component that represents a simple block element.
|
|
46
|
+
*/
|
|
47
|
+
type CodeBlockProps = ComponentWithTextChildrenProps & {
|
|
48
|
+
className?: string;
|
|
49
|
+
};
|
|
50
|
+
type HeadingProps = {
|
|
51
|
+
variant: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
|
|
52
|
+
};
|
|
53
|
+
type HeadingProps2 = ComponentWithTextChildrenProps & {
|
|
54
|
+
className?: string;
|
|
55
|
+
};
|
|
56
|
+
type NavigationStructure = {
|
|
57
|
+
title: string;
|
|
58
|
+
link: string;
|
|
59
|
+
level: number;
|
|
60
|
+
children?: NavigationStructure[];
|
|
61
|
+
};
|
|
62
|
+
type TOCConfig = (toc: Array<TOCItem>) => React$1.ReactNode;
|
|
63
|
+
type ComponentConfig = {
|
|
64
|
+
[Key in Extract<React$1.ElementType, string>]?: React$1.ElementType<React$1.ClassAttributes<HTMLElement> & React$1.HTMLAttributes<HTMLElement>>;
|
|
65
|
+
};
|
|
66
|
+
type MDXConfigProps = {
|
|
67
|
+
components?: ComponentConfig;
|
|
68
|
+
toc?: TOCConfig;
|
|
69
|
+
layout?: React$1.FC<{
|
|
70
|
+
children: React$1.ReactNode;
|
|
71
|
+
toc?: React$1.ReactNode;
|
|
72
|
+
}>;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* This function is used to extract TOC (Table Of Content) from markdown text
|
|
77
|
+
* @param markdown
|
|
78
|
+
* @returns
|
|
79
|
+
*/
|
|
80
|
+
declare function extractTOC(markdown: string): TOCItem[];
|
|
81
|
+
|
|
82
|
+
declare function defineMDXConfig(config: MDXConfigProps): MDXConfigProps;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Renders an MDX content component with a custom code block component.
|
|
86
|
+
*
|
|
87
|
+
* @param {MDXRendererProps} props - The props for the MDX renderer.
|
|
88
|
+
* @param {React.ReactNode} props.children - The MDX content to render.
|
|
89
|
+
* @param {string} [props.className] - An optional CSS class name to apply to the rendered section.
|
|
90
|
+
* @returns {React.ReactElement} - The rendered MDX content with the custom code block component.
|
|
91
|
+
*/
|
|
92
|
+
declare const MDXRenderer: ({ children: MDXContent, className, config, toc: originalTocData, raw, }: MDXRendererProps) => React$1.ReactElement;
|
|
93
|
+
|
|
94
|
+
declare function Markdown({ content, className, overwriteStyle, }: {
|
|
95
|
+
content: string;
|
|
96
|
+
className?: React$1.ComponentProps<'section'>['className'];
|
|
97
|
+
overwriteStyle?: boolean;
|
|
98
|
+
}): react_jsx_runtime.JSX.Element;
|
|
99
|
+
|
|
100
|
+
interface TableOfContentsProps {
|
|
101
|
+
items: TOCItem[];
|
|
102
|
+
}
|
|
103
|
+
declare const TableOfContents: React$1.FC<TableOfContentsProps>;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* A React component that renders a code block with syntax highlighting and a copy button.
|
|
107
|
+
*
|
|
108
|
+
* The component uses the `prism-react-renderer` library to provide syntax highlighting for the code block.
|
|
109
|
+
* It also includes a copy button that allows the user to copy the code to their clipboard.
|
|
110
|
+
*
|
|
111
|
+
* @param {object} props - The component props.
|
|
112
|
+
* @param {string} props.children - The code content to be displayed in the code block.
|
|
113
|
+
* @param {string} [props.className] - The CSS class name to apply to the code block.
|
|
114
|
+
* @returns {React.ReactElement} - The rendered code block component.
|
|
115
|
+
*/
|
|
116
|
+
declare const CodeBlock: ({ children, className, ...rest }: CodeBlockProps) => React$1.ReactElement;
|
|
117
|
+
|
|
118
|
+
type IconProps = React.HTMLAttributes<SVGElement>;
|
|
119
|
+
declare const Icons: {
|
|
120
|
+
logo: (props: IconProps) => react_jsx_runtime.JSX.Element;
|
|
121
|
+
twitter: (props: IconProps) => react_jsx_runtime.JSX.Element;
|
|
122
|
+
gitHub: (props: IconProps) => react_jsx_runtime.JSX.Element;
|
|
123
|
+
radix: (props: IconProps) => react_jsx_runtime.JSX.Element;
|
|
124
|
+
aria: (props: IconProps) => react_jsx_runtime.JSX.Element;
|
|
125
|
+
npm: (props: IconProps) => react_jsx_runtime.JSX.Element;
|
|
126
|
+
yarn: (props: IconProps) => react_jsx_runtime.JSX.Element;
|
|
127
|
+
pnpm: (props: IconProps) => react_jsx_runtime.JSX.Element;
|
|
128
|
+
react: (props: IconProps) => react_jsx_runtime.JSX.Element;
|
|
129
|
+
tailwind: (props: IconProps) => react_jsx_runtime.JSX.Element;
|
|
130
|
+
google: (props: IconProps) => react_jsx_runtime.JSX.Element;
|
|
131
|
+
apple: (props: IconProps) => react_jsx_runtime.JSX.Element;
|
|
132
|
+
paypal: (props: IconProps) => react_jsx_runtime.JSX.Element;
|
|
133
|
+
spinner: (props: IconProps) => react_jsx_runtime.JSX.Element;
|
|
134
|
+
json: (props: IconProps) => react_jsx_runtime.JSX.Element;
|
|
135
|
+
ts: (props: IconProps) => react_jsx_runtime.JSX.Element;
|
|
136
|
+
css: (props: IconProps) => react_jsx_runtime.JSX.Element;
|
|
137
|
+
bash: (props: IconProps) => react_jsx_runtime.JSX.Element;
|
|
138
|
+
v0: (props: IconProps) => react_jsx_runtime.JSX.Element;
|
|
139
|
+
};
|
|
140
|
+
declare function getIconForLanguageExtension(language: string): react_jsx_runtime.JSX.Element;
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Custom hook that tracks which TOC item is currently active based on scroll position
|
|
144
|
+
* @param items - Array of TOC items to observe
|
|
145
|
+
* @param options - IntersectionObserver options
|
|
146
|
+
* @returns The ID of the currently active TOC item
|
|
147
|
+
*/
|
|
148
|
+
declare function useActiveTocItem(items: TOCItem[], options?: IntersectionObserverInit): [string | null, (id: string | null) => void];
|
|
149
|
+
|
|
150
|
+
export { CodeBlock, type CodeBlockProps, type ComponentWithTextChildrenProps, type HeadingProps, type HeadingProps2, Icons, type MDXConfigProps, type MDXPageComponent, MDXRenderer, type MDXRendererProps, Markdown, type NavigationStructure, type TOCItem, TableOfContents, defineMDXConfig, extractTOC, getIconForLanguageExtension, useActiveTocItem };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { Metadata } from 'rasengan';
|
|
2
|
+
import React$1 from 'react';
|
|
3
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A React functional component that represents an MDX page.
|
|
7
|
+
*
|
|
8
|
+
* The `MDXPageComponent` type extends the `React.FC<ReactComponentProps>` type, which means it is a React functional component that accepts the standard props for a React component.
|
|
9
|
+
*
|
|
10
|
+
* The `MDXPageComponent` type also has an optional `metadata` property of type `Metadata`, which can be used to store metadata about the page.
|
|
11
|
+
*/
|
|
12
|
+
type MDXPageComponent = React$1.FC<any> & {
|
|
13
|
+
metadata?: {
|
|
14
|
+
path: string;
|
|
15
|
+
metadata: Metadata;
|
|
16
|
+
};
|
|
17
|
+
toc?: Array<TOCItem>;
|
|
18
|
+
};
|
|
19
|
+
type TOCItem = {
|
|
20
|
+
title: string;
|
|
21
|
+
anchor: {
|
|
22
|
+
id: string;
|
|
23
|
+
text: React$1.ReactNode;
|
|
24
|
+
};
|
|
25
|
+
level: 2 | 3;
|
|
26
|
+
children: Array<Omit<TOCItem, 'children'>>;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* A React functional component that represents a simple block element.
|
|
30
|
+
*/
|
|
31
|
+
type ComponentWithTextChildrenProps = {
|
|
32
|
+
children: React$1.ReactNode;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* A React functional component that represents a simple block element.
|
|
36
|
+
*/
|
|
37
|
+
type MDXRendererProps = {
|
|
38
|
+
children: MDXPageComponent;
|
|
39
|
+
className?: string;
|
|
40
|
+
config?: MDXConfigProps;
|
|
41
|
+
toc?: Array<TOCItem>;
|
|
42
|
+
raw?: string;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* A React functional component that represents a simple block element.
|
|
46
|
+
*/
|
|
47
|
+
type CodeBlockProps = ComponentWithTextChildrenProps & {
|
|
48
|
+
className?: string;
|
|
49
|
+
};
|
|
50
|
+
type HeadingProps = {
|
|
51
|
+
variant: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
|
|
52
|
+
};
|
|
53
|
+
type HeadingProps2 = ComponentWithTextChildrenProps & {
|
|
54
|
+
className?: string;
|
|
55
|
+
};
|
|
56
|
+
type NavigationStructure = {
|
|
57
|
+
title: string;
|
|
58
|
+
link: string;
|
|
59
|
+
level: number;
|
|
60
|
+
children?: NavigationStructure[];
|
|
61
|
+
};
|
|
62
|
+
type TOCConfig = (toc: Array<TOCItem>) => React$1.ReactNode;
|
|
63
|
+
type ComponentConfig = {
|
|
64
|
+
[Key in Extract<React$1.ElementType, string>]?: React$1.ElementType<React$1.ClassAttributes<HTMLElement> & React$1.HTMLAttributes<HTMLElement>>;
|
|
65
|
+
};
|
|
66
|
+
type MDXConfigProps = {
|
|
67
|
+
components?: ComponentConfig;
|
|
68
|
+
toc?: TOCConfig;
|
|
69
|
+
layout?: React$1.FC<{
|
|
70
|
+
children: React$1.ReactNode;
|
|
71
|
+
toc?: React$1.ReactNode;
|
|
72
|
+
}>;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* This function is used to extract TOC (Table Of Content) from markdown text
|
|
77
|
+
* @param markdown
|
|
78
|
+
* @returns
|
|
79
|
+
*/
|
|
80
|
+
declare function extractTOC(markdown: string): TOCItem[];
|
|
81
|
+
|
|
82
|
+
declare function defineMDXConfig(config: MDXConfigProps): MDXConfigProps;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Renders an MDX content component with a custom code block component.
|
|
86
|
+
*
|
|
87
|
+
* @param {MDXRendererProps} props - The props for the MDX renderer.
|
|
88
|
+
* @param {React.ReactNode} props.children - The MDX content to render.
|
|
89
|
+
* @param {string} [props.className] - An optional CSS class name to apply to the rendered section.
|
|
90
|
+
* @returns {React.ReactElement} - The rendered MDX content with the custom code block component.
|
|
91
|
+
*/
|
|
92
|
+
declare const MDXRenderer: ({ children: MDXContent, className, config, toc: originalTocData, raw, }: MDXRendererProps) => React$1.ReactElement;
|
|
93
|
+
|
|
94
|
+
declare function Markdown({ content, className, overwriteStyle, }: {
|
|
95
|
+
content: string;
|
|
96
|
+
className?: React$1.ComponentProps<'section'>['className'];
|
|
97
|
+
overwriteStyle?: boolean;
|
|
98
|
+
}): react_jsx_runtime.JSX.Element;
|
|
99
|
+
|
|
100
|
+
interface TableOfContentsProps {
|
|
101
|
+
items: TOCItem[];
|
|
102
|
+
}
|
|
103
|
+
declare const TableOfContents: React$1.FC<TableOfContentsProps>;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* A React component that renders a code block with syntax highlighting and a copy button.
|
|
107
|
+
*
|
|
108
|
+
* The component uses the `prism-react-renderer` library to provide syntax highlighting for the code block.
|
|
109
|
+
* It also includes a copy button that allows the user to copy the code to their clipboard.
|
|
110
|
+
*
|
|
111
|
+
* @param {object} props - The component props.
|
|
112
|
+
* @param {string} props.children - The code content to be displayed in the code block.
|
|
113
|
+
* @param {string} [props.className] - The CSS class name to apply to the code block.
|
|
114
|
+
* @returns {React.ReactElement} - The rendered code block component.
|
|
115
|
+
*/
|
|
116
|
+
declare const CodeBlock: ({ children, className, ...rest }: CodeBlockProps) => React$1.ReactElement;
|
|
117
|
+
|
|
118
|
+
type IconProps = React.HTMLAttributes<SVGElement>;
|
|
119
|
+
declare const Icons: {
|
|
120
|
+
logo: (props: IconProps) => react_jsx_runtime.JSX.Element;
|
|
121
|
+
twitter: (props: IconProps) => react_jsx_runtime.JSX.Element;
|
|
122
|
+
gitHub: (props: IconProps) => react_jsx_runtime.JSX.Element;
|
|
123
|
+
radix: (props: IconProps) => react_jsx_runtime.JSX.Element;
|
|
124
|
+
aria: (props: IconProps) => react_jsx_runtime.JSX.Element;
|
|
125
|
+
npm: (props: IconProps) => react_jsx_runtime.JSX.Element;
|
|
126
|
+
yarn: (props: IconProps) => react_jsx_runtime.JSX.Element;
|
|
127
|
+
pnpm: (props: IconProps) => react_jsx_runtime.JSX.Element;
|
|
128
|
+
react: (props: IconProps) => react_jsx_runtime.JSX.Element;
|
|
129
|
+
tailwind: (props: IconProps) => react_jsx_runtime.JSX.Element;
|
|
130
|
+
google: (props: IconProps) => react_jsx_runtime.JSX.Element;
|
|
131
|
+
apple: (props: IconProps) => react_jsx_runtime.JSX.Element;
|
|
132
|
+
paypal: (props: IconProps) => react_jsx_runtime.JSX.Element;
|
|
133
|
+
spinner: (props: IconProps) => react_jsx_runtime.JSX.Element;
|
|
134
|
+
json: (props: IconProps) => react_jsx_runtime.JSX.Element;
|
|
135
|
+
ts: (props: IconProps) => react_jsx_runtime.JSX.Element;
|
|
136
|
+
css: (props: IconProps) => react_jsx_runtime.JSX.Element;
|
|
137
|
+
bash: (props: IconProps) => react_jsx_runtime.JSX.Element;
|
|
138
|
+
v0: (props: IconProps) => react_jsx_runtime.JSX.Element;
|
|
139
|
+
};
|
|
140
|
+
declare function getIconForLanguageExtension(language: string): react_jsx_runtime.JSX.Element;
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Custom hook that tracks which TOC item is currently active based on scroll position
|
|
144
|
+
* @param items - Array of TOC items to observe
|
|
145
|
+
* @param options - IntersectionObserver options
|
|
146
|
+
* @returns The ID of the currently active TOC item
|
|
147
|
+
*/
|
|
148
|
+
declare function useActiveTocItem(items: TOCItem[], options?: IntersectionObserverInit): [string | null, (id: string | null) => void];
|
|
149
|
+
|
|
150
|
+
export { CodeBlock, type CodeBlockProps, type ComponentWithTextChildrenProps, type HeadingProps, type HeadingProps2, Icons, type MDXConfigProps, type MDXPageComponent, MDXRenderer, type MDXRendererProps, Markdown, type NavigationStructure, type TOCItem, TableOfContents, defineMDXConfig, extractTOC, getIconForLanguageExtension, useActiveTocItem };
|