@mintlify/astro 0.1.6 → 0.1.8
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.
|
@@ -2,7 +2,7 @@ import { compile } from '@mdx-js/mdx';
|
|
|
2
2
|
import { visit, SKIP } from 'unist-util-visit';
|
|
3
3
|
import { mkdir, writeFile } from 'node:fs/promises';
|
|
4
4
|
import { join, dirname, relative, posix, sep } from 'node:path';
|
|
5
|
-
import { getAST, stringifyTree, findExportedNodes, getExportMapFromTree, isMdxJsxAttribute, createMdxJsxAttribute, allowedComponents, } from '@mintlify/common';
|
|
5
|
+
import { getAST, stringifyTree, findExportedNodes, getExportMapFromTree, isMdxJsxAttribute, createMdxJsxAttribute, allowedComponents, rehypeCodeBlocks, } from '@mintlify/common';
|
|
6
6
|
import { getLogger } from './logger.js';
|
|
7
7
|
const COMPOUND_COMPONENTS = new Set([
|
|
8
8
|
'Accordion',
|
|
@@ -130,6 +130,7 @@ async function compileCompoundComponent(wrapperName, mdxSource) {
|
|
|
130
130
|
outputFormat: 'program',
|
|
131
131
|
development: false,
|
|
132
132
|
providerImportSource: MDX_COMPONENTS_PATH,
|
|
133
|
+
rehypePlugins: [rehypeCodeBlocks],
|
|
133
134
|
});
|
|
134
135
|
const compiledStr = String(compiled)
|
|
135
136
|
.replace(/export default function MDXContent/g, `export function ${wrapperName}`)
|
|
@@ -4,9 +4,11 @@ export declare const components: {
|
|
|
4
4
|
Accordion: (({ title, description, defaultOpen, icon, iconType, children, className, _disabled, trackOpen, trackClose, onMount, topOffset, getInitialOpenFromUrl, onUrlStateChange, _onKeyDownCapture, }: import("@mintlify/components").AccordionProps) => import("react/jsx-runtime").JSX.Element) & {
|
|
5
5
|
Group: ({ children, className }: import("@mintlify/components").AccordionGroupProps) => import("react/jsx-runtime").JSX.Element;
|
|
6
6
|
};
|
|
7
|
+
AccordionGroup: ({ children, className }: import("@mintlify/components").AccordionGroupProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
8
|
Badge: ({ children, className, color, shape, variant: variantProp, stroke, disabled, size, leadIcon, tailIcon: tailIconProp, icon, iconType, iconLibrary, onClick, href, }: import("@mintlify/components").BadgeProps) => import("react/jsx-runtime").JSX.Element;
|
|
8
9
|
Callout: ({ children, variant, icon, iconType, iconLibrary, color, className, ariaLabel, }: import("@mintlify/components").CalloutProps) => import("react/jsx-runtime").JSX.Element;
|
|
9
10
|
Card: ({ title, icon, iconType, iconLibrary, color, horizontal, href, img, children, disabled, cta, arrow, as, className, }: import("@mintlify/components").CardComponentProps) => import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
CardGroup: ({ children, className, cols }: import("@mintlify/components").ColumnsProps) => import("react/jsx-runtime").JSX.Element;
|
|
10
12
|
Check: (props: {
|
|
11
13
|
children: ReactNode;
|
|
12
14
|
className?: string | undefined;
|
|
@@ -57,6 +59,7 @@ export declare const components: {
|
|
|
57
59
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
58
60
|
Panel: ({ children, className, ...props }: import("@mintlify/components").PanelProps) => import("react/jsx-runtime").JSX.Element;
|
|
59
61
|
Property: ({ name, type, location, hidden, default: defaultValue, required, deprecated, children, id, pre, post, className, onMount, navigateToHeaderAriaLabel, defaultLabel, requiredLabel, deprecatedLabel, }: import("@mintlify/components").PropertyProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
62
|
+
ResponseField: ({ name, type, location, hidden, default: defaultValue, required, deprecated, children, id, pre, post, className, onMount, navigateToHeaderAriaLabel, defaultLabel, requiredLabel, deprecatedLabel, }: import("@mintlify/components").PropertyProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
60
63
|
Steps: {
|
|
61
64
|
({ children, titleSize, className }: import("@mintlify/components").StepsProps): import("react/jsx-runtime").JSX.Element;
|
|
62
65
|
Item: ({ stepNumber, icon, iconType, iconLibrary, title, children, titleSize, className, isLast, id, noAnchor, scrollElementIntoView, onRegisterHeading, onUnregisterHeading, _hasContext, onCopyAnchorLink, }: import("@mintlify/components").StepsItemProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -3,9 +3,11 @@ import { Accordion, Badge, Callout, Card, Check, CodeBlock, CodeGroup, Color, Co
|
|
|
3
3
|
const Wrapper = ({ children }) => (_jsx("div", { children: children }));
|
|
4
4
|
const MintlifyComponents = {
|
|
5
5
|
Accordion,
|
|
6
|
+
AccordionGroup: Accordion.Group,
|
|
6
7
|
Badge,
|
|
7
8
|
Callout,
|
|
8
9
|
Card,
|
|
10
|
+
CardGroup: Columns,
|
|
9
11
|
Check,
|
|
10
12
|
CodeBlock,
|
|
11
13
|
CodeGroup,
|
|
@@ -20,6 +22,7 @@ const MintlifyComponents = {
|
|
|
20
22
|
Note,
|
|
21
23
|
Panel,
|
|
22
24
|
Property,
|
|
25
|
+
ResponseField: Property,
|
|
23
26
|
Steps,
|
|
24
27
|
Tabs,
|
|
25
28
|
Tile,
|
|
@@ -30,10 +33,8 @@ const MintlifyComponents = {
|
|
|
30
33
|
Warning,
|
|
31
34
|
};
|
|
32
35
|
const placeholderComponents = {
|
|
33
|
-
AccordionGroup: Wrapper,
|
|
34
|
-
ApiPlayground: Wrapper,
|
|
35
|
-
CardGroup: Wrapper,
|
|
36
36
|
Column: Wrapper,
|
|
37
|
+
ApiPlayground: Wrapper,
|
|
37
38
|
CustomCode: Wrapper,
|
|
38
39
|
CustomComponent: Wrapper,
|
|
39
40
|
DynamicCustomComponent: Wrapper,
|
|
@@ -47,7 +48,6 @@ const placeholderComponents = {
|
|
|
47
48
|
PreviewButton: Wrapper,
|
|
48
49
|
RequestExample: Wrapper,
|
|
49
50
|
ResponseExample: Wrapper,
|
|
50
|
-
ResponseField: Wrapper,
|
|
51
51
|
Snippet: Wrapper,
|
|
52
52
|
SnippetGroup: Wrapper,
|
|
53
53
|
View: Wrapper,
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const VIRTUAL_MODULE_ID = 'mintlify:components';
|
|
2
|
+
const RESOLVED_VIRTUAL_MODULE_ID = '\0mintlify:components';
|
|
3
|
+
export function virtualComponentsPlugin(overrides) {
|
|
4
|
+
return {
|
|
5
|
+
name: 'mintlify-virtual-components',
|
|
6
|
+
resolveId(id) {
|
|
7
|
+
if (id === VIRTUAL_MODULE_ID) {
|
|
8
|
+
return RESOLVED_VIRTUAL_MODULE_ID;
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
load(id) {
|
|
12
|
+
if (id !== RESOLVED_VIRTUAL_MODULE_ID)
|
|
13
|
+
return;
|
|
14
|
+
const entries = Object.entries(overrides);
|
|
15
|
+
if (entries.length === 0) {
|
|
16
|
+
return `export { components, useMDXComponents } from '@mintlify/astro/components';`;
|
|
17
|
+
}
|
|
18
|
+
const importLines = entries.map(([name, absPath]) => `import ${name} from '${absPath}';`);
|
|
19
|
+
const overrideKeys = entries.map(([name]) => name).join(', ');
|
|
20
|
+
return [
|
|
21
|
+
`import { components as defaultComponents, useMDXComponents as defaultUseMDXComponents } from '@mintlify/astro/components';`,
|
|
22
|
+
...importLines,
|
|
23
|
+
`const overrides = { ${overrideKeys} };`,
|
|
24
|
+
`export const components = { ...defaultComponents, ...overrides };`,
|
|
25
|
+
`export function useMDXComponents() {`,
|
|
26
|
+
` return { ...defaultUseMDXComponents(), ...overrides };`,
|
|
27
|
+
`}`,
|
|
28
|
+
].join('\n');
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
}
|