@mintlify/astro 0.1.8 → 1.0.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 +26 -14
- package/dist/helpers.js +2 -2
- package/dist/index.js +20 -16
- 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 +13 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Mintlify, Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
# @mintlify/astro
|
|
2
2
|
|
|
3
|
-
Mintlify integration for Astro.
|
|
3
|
+
Mintlify integration for [Astro](https://astro.build). Syncs Mintlify-style docs content into Astro content collections and provides MDX components for rendering docs pages.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
npm install @mintlify/
|
|
8
|
+
npm install @mintlify/astro
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
+
Peer dependencies: `astro`, `@astrojs/react`, `@astrojs/mdx`, `@mintlify/components`, and `react`.
|
|
12
|
+
|
|
11
13
|
## Usage
|
|
12
14
|
|
|
13
|
-
### 1
|
|
15
|
+
### 1. Configure the Astro integration
|
|
14
16
|
|
|
15
17
|
```ts
|
|
16
18
|
// astro.config.mjs
|
|
@@ -24,28 +26,38 @@ export default defineConfig({
|
|
|
24
26
|
});
|
|
25
27
|
```
|
|
26
28
|
|
|
27
|
-
### 2
|
|
29
|
+
### 2. Use MDX components in a docs page
|
|
28
30
|
|
|
29
31
|
```astro
|
|
30
32
|
---
|
|
31
33
|
import { render } from 'astro:content';
|
|
32
34
|
import { components } from '@mintlify/astro/components';
|
|
33
35
|
---
|
|
36
|
+
|
|
34
37
|
<Content components={components} />
|
|
35
38
|
```
|
|
36
39
|
|
|
37
40
|
## Expected docs structure
|
|
38
41
|
|
|
39
|
-
- `./docs/docs.json`
|
|
40
|
-
- `./docs/**/*.mdx`
|
|
41
|
-
- `./docs/snippets/*` (optional)
|
|
42
|
-
-
|
|
42
|
+
- `./docs/docs.json` — navigation and site configuration
|
|
43
|
+
- `./docs/**/*.mdx` — page content
|
|
44
|
+
- `./docs/snippets/*` — reusable content snippets (optional)
|
|
45
|
+
- Static assets anywhere in `./docs/**` (`.png`, `.jpg`, `.jpeg`, `.gif`, `.webp`, `.svg`, `.ico`, `.mp4`, `.webm`, `.mp3`, `.wav`, `.css`, `.woff`, `.woff2`, `.ttf`, `.eot`)
|
|
46
|
+
|
|
47
|
+
At build setup time, the integration generates files under `.mintlify/`:
|
|
48
|
+
|
|
49
|
+
| Directory | Contents |
|
|
50
|
+
|-----------|----------|
|
|
51
|
+
| `.mintlify/docs/` | Synced page content |
|
|
52
|
+
| `.mintlify/components/` | Extracted React components |
|
|
53
|
+
| `.mintlify/static/` | Static assets from docs |
|
|
54
|
+
|
|
55
|
+
These are generated build artifacts and should not be edited manually.
|
|
56
|
+
|
|
57
|
+
## Contributing
|
|
43
58
|
|
|
44
|
-
|
|
59
|
+
See [CONTRIBUTING.md](./CONTRIBUTING.md) and [DEVELOPMENT.md](./DEVELOPMENT.md).
|
|
45
60
|
|
|
46
|
-
|
|
47
|
-
- `.mintlify/components/**/*` (extracted React components)
|
|
48
|
-
- `.mintlify/static/**/*` (static assets from docs)
|
|
49
|
-
- `.mintlify/generated/favicons.json` (when favicon is configured)
|
|
61
|
+
## License
|
|
50
62
|
|
|
51
|
-
|
|
63
|
+
[MIT](./LICENSE)
|
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 }) => {
|
|
@@ -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.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "Mintlify integration for Astro",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -26,10 +26,19 @@
|
|
|
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
|
-
"license": "
|
|
33
|
+
"license": "MIT",
|
|
34
|
+
"repository": {
|
|
35
|
+
"type": "git",
|
|
36
|
+
"url": "https://github.com/mintlify/astro.git"
|
|
37
|
+
},
|
|
38
|
+
"bugs": {
|
|
39
|
+
"url": "https://github.com/mintlify/astro/issues"
|
|
40
|
+
},
|
|
41
|
+
"homepage": "https://github.com/mintlify/astro#readme",
|
|
33
42
|
"publishConfig": {
|
|
34
43
|
"access": "public",
|
|
35
44
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -47,6 +56,7 @@
|
|
|
47
56
|
"astro": "^5.17.1",
|
|
48
57
|
"mdast": "^2.3.2",
|
|
49
58
|
"mdast-util-mdx": "^3.0.0",
|
|
59
|
+
"prettier": "^3.8.1",
|
|
50
60
|
"react": "^19.2.3",
|
|
51
61
|
"react-dom": "^19.2.3",
|
|
52
62
|
"typescript": "^5.9.3"
|