@mintlify/astro 0.1.7 → 0.1.9
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 -0
- package/dist/helpers.js +2 -2
- package/dist/index.js +20 -16
- package/dist/utils/mintlify-components.d.ts +3 -0
- package/dist/utils/mintlify-components.js +4 -4
- package/dist/utils/serve-docs-assets.js +3 -1
- package/dist/utils/static-assets.js +1 -0
- package/dist/utils/write-raw-md.d.ts +1 -0
- package/dist/utils/write-raw-md.js +34 -0
- package/package.json +4 -2
package/README.md
CHANGED
package/dist/helpers.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { divisions } from '@mintlify/validation';
|
|
1
|
+
import { divisions, } from '@mintlify/validation';
|
|
2
2
|
export function isNavPage(entry) {
|
|
3
3
|
return 'href' in entry && 'title' in entry;
|
|
4
4
|
}
|
|
@@ -140,7 +140,7 @@ export function getFooterPages(entries, currentPath) {
|
|
|
140
140
|
};
|
|
141
141
|
}
|
|
142
142
|
function flattenPages(entries) {
|
|
143
|
-
return entries.flatMap((x) => isNavGroup(x) ? flattenPages(x.pages) : [x]);
|
|
143
|
+
return entries.flatMap((x) => (isNavGroup(x) ? flattenPages(x.pages) : [x]));
|
|
144
144
|
}
|
|
145
145
|
/**
|
|
146
146
|
* Finds the group label that contains the given path.
|
package/dist/index.js
CHANGED
|
@@ -11,6 +11,7 @@ import { readDocsConfig } from './utils/read-docs-config.js';
|
|
|
11
11
|
import { readPageContent } from './utils/read-page-content.js';
|
|
12
12
|
import { createStaticAssetMiddleware } from './utils/serve-docs-assets.js';
|
|
13
13
|
import { writePageContent } from './utils/write-page-content.js';
|
|
14
|
+
import { writeRawMd } from './utils/write-raw-md.js';
|
|
14
15
|
export { readDocsConfig } from './utils/read-docs-config.js';
|
|
15
16
|
export function mintlify(options) {
|
|
16
17
|
let docsDir;
|
|
@@ -38,22 +39,25 @@ export function mintlify(options) {
|
|
|
38
39
|
const docsConfig = await readDocsConfig(docsDir);
|
|
39
40
|
const pagePaths = getAllPathsInDocsNav(docsConfig.navigation);
|
|
40
41
|
logger.info(`Found ${pagePaths.length} pages to sync`);
|
|
41
|
-
await Promise.all(
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
content,
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
42
|
+
await Promise.all([
|
|
43
|
+
writeRawMd(pagePaths, docsDir, staticDir),
|
|
44
|
+
...pagePaths.map(async (pagePath) => {
|
|
45
|
+
try {
|
|
46
|
+
const { content, slug } = await readPageContent(pagePath, docsDir);
|
|
47
|
+
await writePageContent({
|
|
48
|
+
content,
|
|
49
|
+
slug,
|
|
50
|
+
contentDir,
|
|
51
|
+
componentsDir,
|
|
52
|
+
userComponents,
|
|
53
|
+
snippets,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
logger.warn(`Failed to read content for ${pagePath}: ${error}`);
|
|
58
|
+
}
|
|
59
|
+
}),
|
|
60
|
+
]);
|
|
57
61
|
logger.info(`Synced ${pagePaths.length} pages`);
|
|
58
62
|
},
|
|
59
63
|
'astro:server:setup': ({ server }) => {
|
|
@@ -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,
|
|
@@ -14,7 +14,9 @@ export function createStaticAssetMiddleware(staticDir) {
|
|
|
14
14
|
catch {
|
|
15
15
|
return next();
|
|
16
16
|
}
|
|
17
|
-
const relativePath = pathname.startsWith('/')
|
|
17
|
+
const relativePath = pathname.startsWith('/')
|
|
18
|
+
? pathname.slice(1)
|
|
19
|
+
: pathname;
|
|
18
20
|
if (!relativePath)
|
|
19
21
|
return next();
|
|
20
22
|
if (!isSupportedStaticAsset(relativePath))
|
|
@@ -16,6 +16,7 @@ const SUPPORTED_STATIC_ASSETS = {
|
|
|
16
16
|
'.woff2': 'font/woff2',
|
|
17
17
|
'.ttf': 'font/ttf',
|
|
18
18
|
'.eot': 'application/vnd.ms-fontobject',
|
|
19
|
+
'.md': 'text/plain',
|
|
19
20
|
};
|
|
20
21
|
export function isSupportedStaticAsset(pathname) {
|
|
21
22
|
const extension = posix.extname(pathname).toLowerCase();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function writeRawMd(pagePaths: string[], docsDir: string, outputDir: string): Promise<void>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { mkdir, readFile, writeFile } from 'node:fs/promises';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { parseFrontmatter } from '@mintlify/common';
|
|
4
|
+
export async function writeRawMd(pagePaths, docsDir, outputDir) {
|
|
5
|
+
await Promise.all(pagePaths.map(async (pagePath) => {
|
|
6
|
+
let content;
|
|
7
|
+
try {
|
|
8
|
+
content = await readFile(join(docsDir, `${pagePath}.mdx`));
|
|
9
|
+
}
|
|
10
|
+
catch {
|
|
11
|
+
try {
|
|
12
|
+
content = await readFile(join(docsDir, `${pagePath}.md`));
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
let filePath;
|
|
19
|
+
if (pagePath === 'index') {
|
|
20
|
+
filePath = join(outputDir, 'index.md');
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
const parts = pagePath.split('/');
|
|
24
|
+
const fileName = parts.pop() + '.md';
|
|
25
|
+
const dirPath = join(outputDir, ...parts);
|
|
26
|
+
if (parts.length > 0) {
|
|
27
|
+
await mkdir(dirPath, { recursive: true });
|
|
28
|
+
}
|
|
29
|
+
filePath = join(dirPath, fileName);
|
|
30
|
+
}
|
|
31
|
+
const { body } = parseFrontmatter(content.toString());
|
|
32
|
+
await writeFile(filePath, body);
|
|
33
|
+
}));
|
|
34
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mintlify/astro",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"description": "Mintlify integration for Astro",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -26,7 +26,8 @@
|
|
|
26
26
|
"scripts": {
|
|
27
27
|
"prepare": "npm run build",
|
|
28
28
|
"build": "tsc",
|
|
29
|
-
"type": "tsc --noEmit"
|
|
29
|
+
"type": "tsc --noEmit",
|
|
30
|
+
"format": "prettier --write ."
|
|
30
31
|
},
|
|
31
32
|
"author": "Mintlify, Inc.",
|
|
32
33
|
"license": "ISC",
|
|
@@ -47,6 +48,7 @@
|
|
|
47
48
|
"astro": "^5.17.1",
|
|
48
49
|
"mdast": "^2.3.2",
|
|
49
50
|
"mdast-util-mdx": "^3.0.0",
|
|
51
|
+
"prettier": "^3.8.1",
|
|
50
52
|
"react": "^19.2.3",
|
|
51
53
|
"react-dom": "^19.2.3",
|
|
52
54
|
"typescript": "^5.9.3"
|