@mintlify/astro 0.1.5 → 0.1.7

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/dist/helpers.js CHANGED
@@ -1,4 +1,3 @@
1
- import { sep } from 'node:path';
2
1
  import { divisions } from '@mintlify/validation';
3
2
  export function isNavPage(entry) {
4
3
  return 'href' in entry && 'title' in entry;
@@ -7,7 +6,7 @@ export function isNavGroup(entry) {
7
6
  return 'group' in entry && 'pages' in entry;
8
7
  }
9
8
  function normalizePath(path) {
10
- let normalized = sep !== '/' ? path.replaceAll(sep, '/') : path;
9
+ let normalized = path.replaceAll('\\', '/');
11
10
  if (normalized.length > 1 && normalized.endsWith('/')) {
12
11
  normalized = normalized.slice(0, -1);
13
12
  }
@@ -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}`)
@@ -0,0 +1,2 @@
1
+ import type { Plugin } from 'vite';
2
+ export declare function virtualComponentsPlugin(overrides: Record<string, string>): Plugin;
@@ -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
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mintlify/astro",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "description": "Mintlify integration for Astro",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",