@alvincrespo/hashnode-content-converter - v0.2.2
    Preparing search index...

    Class ImageProcessor

    ImageProcessor handles downloading images from Hashnode CDN and updating markdown references to use local file paths.

    This processor:

    • Extracts image URLs from markdown syntax
    • Downloads images using the ImageDownloader service
    • Replaces CDN URLs with local relative paths
    • Skips already-downloaded images using marker-based tracking
    • Tracks download failures and HTTP 403 errors
    • Implements intelligent retry: skips permanent 403s, retries transient failures

    Marker-Based Retry Strategy:

    • Creates .downloaded-markers/ directory in each blog post directory
    • Tracks download attempts with marker files:
      • Success: Empty .marker file (e.g., uuid.png.marker)
      • Transient failure: .marker file with error message (will retry)
      • Permanent failure (403): .marker.403 file (won't retry)
    const processor = new ImageProcessor({
    maxRetries: 3,
    downloadDelayMs: 200
    });

    const result = await processor.process(
    markdown,
    '/path/to/blog/post-slug'
    );

    console.log(`Downloaded ${result.imagesDownloaded} images`);
    if (result.errors.length > 0) {
    const forbidden = result.errors.filter(e => e.is403);
    console.log(`HTTP 403 errors: ${forbidden.length}`);
    }
    Index

    Constructors

    Methods

    Constructors

    Methods

    • Process markdown content: extract image URLs, download images, and replace CDN URLs with local relative paths.

      Uses marker-based tracking to enable intelligent retry:

      • Skips successfully downloaded images (file + success marker exist)
      • Skips permanent HTTP 403 failures (403 marker exists)
      • Retries transient failures (error marker or no marker)

      Only replaces CDN URLs with local paths on successful download. Failed images keep CDN URLs, making missing images visible in rendered markdown.

      Parameters

      • markdown: string

        Markdown content from MarkdownTransformer

      • blogDir: string

        Absolute path to blog post directory where images should be saved

      Returns Promise<ImageProcessingResult>

      Processing result with updated markdown and statistics

      If blogDir doesn't exist or isn't accessible

      const result = await processor.process(
      '![Image](https://cdn.hashnode.com/.../uuid.png)',
      '/blog/my-post'
      );
      // result.markdown === '![Image](./uuid.png)'
      // result.imagesDownloaded === 1