Skip to content

import — overview

Index

Functions

runImport

function runImport(dir: string, format: ImportFormat, name?: string): ImportResult
TypeScript

Use runImport to migrate existing documentation from another platform into skrypt's format in a single call.

Reach for this when you've detected (or already know) the format of a docs directory and want to pull its content into your skrypt project. It's the bridge between "I have a Mintlify/Docusaurus/GitBook/ReadMe site" and "I have skrypt-compatible MDX."

runImport inspects the format argument and delegates to the correct platform-specific importer automatically — you don't need to call individual importers yourself.

Parameters

NameTypeRequiredDescription
dirstringYesPath to the root of the existing docs directory to import from. Must contain the source platform's files (e.g., mint.json for Mintlify, docusaurus.config.js for Docusaurus).
formatImportFormatYesThe doc platform to import from. Accepted values: "mintlify", "docusaurus", "gitbook", "readme", "confluence". Determines which importer runs.
namestringNoOverride name for the imported project. Defaults to the name detected from the source platform's config file when omitted.

Returns

Returns an ImportResult object containing the imported pages, detected metadata, and any warnings about content that couldn't be converted. Check result.warnings before writing output — some platform-specific components (custom MDX, embeds) may need manual cleanup.

Heads up

  • The dir path must point to the root of the source docs project, not a subdirectory. Importers look for platform config files (e.g., mint.json, book.json) at that root to bootstrap the import.
  • Passing a format that doesn't match the actual contents of dir won't throw immediately — it will fail when the importer can't find its expected config file.

Example:

type ImportFormat = "mintlify" | "docusaurus" | "gitbook" | "readme" | "confluence";

interface ImportedPage {
  slug: string;
  title: string;
  content: string;
}

interface ImportResult {
  pages: ImportedPage[];
  projectName: string;
  warnings: string[];
}

// Inline mock of runImport — replace with actual autodocs integration
function runImport(dir: string, format: ImportFormat, name?: string): ImportResult {
  const mockPages: ImportedPage[] = [
    { slug: "getting-started", title: "Getting Started", content: "# Getting Started\n\nWelcome to the API." },
    { slug: "authentication", title: "Authentication", content: "# Authentication\n\nUse Bearer tokens." },
  ];

  return {
    pages: mockPages,
    projectName: name ?? "my-api-docs",
    warnings: ["Custom <Callout> component on page 'authentication' was converted to blockquote."],
  };
}

try {
  const result = runImport("./legacy-docs", "mintlify", "acme-api-docs");

  if (result.warnings.length > 0) {
    console.warn("Import completed with warnings:");
    result.warnings.forEach((w) => console.warn(" -", w));
  }

  console.log(`Imported ${result.pages.length} pages into project "${result.projectName}"`);
  console.log("Pages:", result.pages.map((p) => p.slug));
  // Output:
  // Import completed with warnings:
  //  - Custom <Callout> component on page 'authentication' was converted to blockquote.
  // Imported 2 pages into project "acme-api-docs"
  // Pages: [ 'getting-started', 'authentication' ]
} catch (err) {
  console.error("Import failed:", err);
}
TypeScript
Was this helpful?