Skip to content

import — mintlify

Mintlify

Functions

importMintlify

function importMintlify(dir: string, name?: string): ImportResult
TypeScript

Use importMintlify to migrate an existing Mintlify documentation site into skrypt's format, preserving your content structure and converting Mintlify-specific MDX components automatically.

Reach for this when you're switching a project from Mintlify to skrypt and want to bring your existing .mdx files along — callouts, tabs, code groups, and image paths included — rather than rewriting from scratch.

It scans the target directory for your Mintlify config and all MDX files, then transforms Mintlify-specific syntax (like <Callout>, <Tabs>, and <Steps>) into skrypt-compatible equivalents. Image paths are rewritten to match the new output structure.

Parameters

NameTypeRequiredDescription
dirstringYesPath to the root of your existing Mintlify project — the directory containing mint.json and your MDX content.
namestringNoDisplay name for the imported documentation set. Defaults to the directory name if omitted.

Returns

Returns an ImportResult object containing the imported pages, transformation statistics (how many callouts, tabs, images, etc. were converted), and any warnings about content that couldn't be automatically migrated. Pass the result to skrypt's output writer to generate the final MDX files, or inspect result.stats to audit what was transformed before writing.

Heads up

  • mint.json must exist at the root of dir — the import will fail if the Mintlify config is missing or malformed.
  • Custom Mintlify components beyond the standard set (callouts, tabs, steps, accordions) won't be auto-converted and will appear in result.stats.other so you can handle them manually.

Example:

type ImportedPage = {
  path: string;
  content: string;
  frontmatter: Record<string, unknown>;
};

type TransformStats = {
  callouts: number;
  tabs: number;
  codeGroups: number;
  steps: number;
  accordions: number;
  images: number;
  other: number;
};

type ImportResult = {
  name: string;
  pages: ImportedPage[];
  stats: TransformStats;
  warnings: string[];
};

// Mock implementation — replace with actual importMintlify from autodocs
function importMintlify(dir: string, name?: string): ImportResult {
  return {
    name: name ?? "stripe-docs",
    pages: [
      {
        path: "getting-started/quickstart.mdx",
        content: "# Quickstart\n\nGet up and running in 5 minutes.",
        frontmatter: { title: "Quickstart", description: "Get started with the Stripe API" },
      },
      {
        path: "api-reference/payments.mdx",
        content: "# Payments\n\nCreate and manage payment intents.",
        frontmatter: { title: "Payments" },
      },
    ],
    stats: { callouts: 14, tabs: 6, codeGroups: 9, steps: 3, accordions: 2, images: 21, other: 1 },
    warnings: [
      "Custom component <ApiPlayground> on api-reference/payments.mdx:42 was not converted automatically.",
    ],
  };
}

try {
  const result = importMintlify("./stripe-mintlify-docs", "Stripe API Docs");

  console.log(`Imported "${result.name}" — ${result.pages.length} pages`);
  console.log("Transformation summary:", result.stats);

  if (result.warnings.length > 0) {
    console.warn("Manual review needed:");
    result.warnings.forEach((w) => console.warn(" •", w));
  }

  // Next step: write result.pages to your skrypt output directory
  result.pages.forEach((page) => {
    console.log(`  ✓ ${page.path}`);
  });
} catch (err) {
  console.error("Import failed:", err);
}

// Expected output:
// Imported "Stripe API Docs" — 2 pages
// Transformation summary: { callouts: 14, tabs: 6, codeGroups: 9, steps: 3, accordions: 2, images: 21, other: 1 }
// Manual review needed:
//  • Custom component <ApiPlayground> on api-reference/payments.mdx:42 was not converted automatically.
//   ✓ getting-started/quickstart.mdx
//   ✓ api-reference/payments.mdx
TypeScript
Was this helpful?