@marvalt/wadapter 2.3.26 → 2.3.29

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.
@@ -113,39 +113,37 @@ export declare class WordPressClient {
113
113
  };
114
114
  site_name?: string;
115
115
  site_description?: string;
116
- }>;
117
- /**
118
- * Fetch Theme Styles from custom endpoint
119
- * @returns Theme customization settings (typography, colors, backgrounds, shadows, layout)
120
- */
121
- getThemeStyles(): Promise<{
122
- typography?: {
123
- heading_font_family?: string;
124
- body_font_family?: string;
125
- base_font_size?: string;
126
- line_height?: string;
127
- };
128
- colors?: {
129
- primary?: string;
130
- secondary?: string;
131
- text?: string;
132
- background?: string;
133
- };
134
- theme_palette?: Record<string, string>;
135
- backgrounds?: {
136
- image?: string;
137
- repeat?: string;
138
- position?: string;
139
- size?: string;
140
- };
141
- shadows?: {
142
- box_shadow?: string;
143
- text_shadow?: string;
144
- };
145
- layout?: {
146
- container_max_width?: string;
147
- wide_container_max_width?: string;
148
- content_padding?: string;
116
+ theme_styles?: {
117
+ typography?: {
118
+ heading_font_family?: string;
119
+ body_font_family?: string;
120
+ base_font_size?: string;
121
+ font_size_presets?: Record<string, string>;
122
+ line_height?: string;
123
+ };
124
+ colors?: {
125
+ primary?: string;
126
+ secondary?: string;
127
+ text?: string;
128
+ heading?: string;
129
+ background?: string;
130
+ };
131
+ theme_palette?: Record<string, string>;
132
+ layout?: {
133
+ container_max_width?: string;
134
+ wide_container_max_width?: string;
135
+ content_padding?: string;
136
+ };
137
+ backgrounds?: {
138
+ image?: string;
139
+ repeat?: string;
140
+ position?: string;
141
+ size?: string;
142
+ };
143
+ shadows?: {
144
+ box_shadow?: string;
145
+ text_shadow?: string;
146
+ };
149
147
  };
150
148
  }>;
151
149
  }
@@ -1 +1 @@
1
- {"version":3,"file":"wordpress-client.d.ts","sourceRoot":"","sources":["../../src/client/wordpress-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,OA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BACd,OAAO,CAAC,EAAE,MAAM,CAAC;gBACjB,UAAU,CAAC,EAAE,MAAM,CAAC;aACrB,CAAC;YACF,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;YACvC,MAAM,CAAC,EAAE;gBACP,mBAAmB,CAAC,EAAE,MAAM,CAAC;gBAC7B,wBAAwB,CAAC,EAAE,MAAM,CAAC;gBAClC,eAAe,CAAC,EAAE,MAAM,CAAC;aAC1B,CAAC;YACF,WAAW,CAAC,EAAE;gBACZ,KAAK,CAAC,EAAE,MAAM,CAAC;gBACf,MAAM,CAAC,EAAE,MAAM,CAAC;gBAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;gBAClB,IAAI,CAAC,EAAE,MAAM,CAAC;aACf,CAAC;YACF,OAAO,CAAC,EAAE;gBACR,UAAU,CAAC,EAAE,MAAM,CAAC;gBACpB,WAAW,CAAC,EAAE,MAAM,CAAC;aACtB,CAAC;SACH,CAAC;KACH,CAAC;CA4CH"}
@@ -15,7 +15,7 @@
15
15
  * See the GNU General Public License for more details.
16
16
  */
17
17
  import { WordPressConfig, WordPressPost, WordPressPage, WordPressMedia } from '../../types/wordpress';
18
- import type { SiteSettings, ThemeStyles } from '../../static/wordpress-static';
18
+ import type { SiteSettings } from '../../static/wordpress-static';
19
19
  export interface WordPressGeneratorConfig extends WordPressConfig {
20
20
  outputPath: string;
21
21
  frontendId?: string;
@@ -34,7 +34,38 @@ export interface StaticDataStore {
34
34
  title: string;
35
35
  };
36
36
  site_settings?: SiteSettings;
37
- theme_styles?: ThemeStyles;
37
+ theme_styles?: {
38
+ typography?: {
39
+ heading_font_family?: string;
40
+ body_font_family?: string;
41
+ base_font_size?: string;
42
+ font_size_presets?: Record<string, string>;
43
+ line_height?: string;
44
+ };
45
+ colors?: {
46
+ primary?: string;
47
+ secondary?: string;
48
+ text?: string;
49
+ heading?: string;
50
+ background?: string;
51
+ };
52
+ theme_palette?: Record<string, string>;
53
+ layout?: {
54
+ container_max_width?: string;
55
+ wide_container_max_width?: string;
56
+ content_padding?: string;
57
+ };
58
+ backgrounds?: {
59
+ image?: string;
60
+ repeat?: string;
61
+ position?: string;
62
+ size?: string;
63
+ };
64
+ shadows?: {
65
+ box_shadow?: string;
66
+ text_shadow?: string;
67
+ };
68
+ };
38
69
  config: {
39
70
  frontend_id: string;
40
71
  frontend_name: string;
@@ -50,29 +81,7 @@ export interface StaticDataStore {
50
81
  }
51
82
  export declare class WordPressGenerator {
52
83
  private config;
53
- private imageDownloadCache;
54
84
  constructor(config: WordPressGeneratorConfig);
55
- /**
56
- * Check if an image has Cloudflare URL available
57
- */
58
- private hasCloudflareImage;
59
- /**
60
- * Extract image URL from various sources (media item, featured media, etc.)
61
- */
62
- private extractImageUrl;
63
- /**
64
- * Process images in blocks recursively
65
- */
66
- private extractImageUrlsFromBlocks;
67
- /**
68
- * Process and download images if needed
69
- * Downloads images when Cloudflare images are not available (works in both direct and proxy modes)
70
- */
71
- private processImages;
72
- /**
73
- * Replace WordPress image URLs with local paths in an item
74
- */
75
- private replaceImageUrls;
76
85
  generateStaticData(): Promise<StaticDataStore>;
77
86
  private writeStaticData;
78
87
  generatePostsOnly(): Promise<WordPressPost[]>;
@@ -1 +1 @@
1
- {"version":3,"file":"wordpress-generator.d.ts","sourceRoot":"","sources":["../../../src/generators/wordpress/wordpress-generator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAKH,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,aAAa,EAAE,cAAc,EAAmC,MAAM,uBAAuB,CAAC;AAIvI,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAG/E,MAAM,WAAW,wBAAyB,SAAQ,eAAe;IAC/D,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;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AkB,IAAI,OAAO,CAAC,eAAe,CAAC;IA+OpD,OAAO,CAAC,eAAe;IAWjB,iBAAiB,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC;IAK7C,iBAAiB,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC;IAK7C,iBAAiB,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;CAIrD;AAGD,wBAAsB,qBAAqB,CAAC,MAAM,EAAE,wBAAwB,GAAG,OAAO,CAAC,eAAe,CAAC,CAGtG"}
@@ -2,7 +2,6 @@
2
2
 
3
3
  var fs = require('fs');
4
4
  var path = require('path');
5
- var crypto = require('crypto');
6
5
 
7
6
  /**
8
7
  * @license GPL-3.0-or-later
@@ -266,13 +265,6 @@ class WordPressClient {
266
265
  async getSettings() {
267
266
  return this.makeRequest('/wp-custom/v1/settings');
268
267
  }
269
- /**
270
- * Fetch Theme Styles from custom endpoint
271
- * @returns Theme customization settings (typography, colors, backgrounds, shadows, layout)
272
- */
273
- async getThemeStyles() {
274
- return this.makeRequest('/wp-custom/v1/theme-styles');
275
- }
276
268
  }
277
269
 
278
270
  let document;
@@ -474,101 +466,6 @@ function addBlockFromStack(endOffset) {
474
466
  output.push(block);
475
467
  }
476
468
 
477
- /**
478
- * @license GPL-3.0-or-later
479
- *
480
- * This file is part of the MarVAlt Open SDK.
481
- * Copyright (c) 2025 Vibune Pty Ltd.
482
- *
483
- * This program is free software: you can redistribute it and/or modify
484
- * it under the terms of the GNU General Public License as published by
485
- * the Free Software Foundation, either version 3 of the License, or
486
- * (at your option) any later version.
487
- *
488
- * This program is distributed in the hope that it will be useful,
489
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
490
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
491
- * See the GNU General Public License for more details.
492
- */
493
- /**
494
- * Generate a unique filename for an image based on its URL
495
- */
496
- function generateImageFilename(imageUrl) {
497
- // Create hash from URL for uniqueness
498
- const hash = crypto.createHash('md5').update(imageUrl).digest('hex').substring(0, 12);
499
- // Try to extract extension from URL
500
- const urlPath = new URL(imageUrl).pathname;
501
- const ext = path.extname(urlPath) || '.jpg'; // Default to .jpg if no extension
502
- return `${hash}${ext}`;
503
- }
504
- /**
505
- * Download an image from WordPress and save it to public/images
506
- * Returns the local path relative to public directory (e.g., /images/abc123.jpg)
507
- * Returns null if download fails
508
- */
509
- async function downloadImageToPublic(imageUrl, config) {
510
- try {
511
- // Generate filename
512
- const filename = generateImageFilename(imageUrl);
513
- const localPath = path.join(config.outputDir, filename);
514
- const publicPath = `/images/${filename}`;
515
- // Check if image already exists
516
- if (fs.existsSync(localPath)) {
517
- return publicPath;
518
- }
519
- // Ensure output directory exists
520
- fs.mkdirSync(config.outputDir, { recursive: true });
521
- // Prepare fetch options with authentication if provided
522
- const fetchOptions = {
523
- method: 'GET',
524
- headers: {
525
- 'User-Agent': 'MarVAlt-Wadapter/1.0',
526
- },
527
- signal: AbortSignal.timeout(config.timeout || 30000), // 30 second timeout
528
- };
529
- // Add Basic Auth if credentials provided
530
- if (config.username && config.password) {
531
- const auth = Buffer.from(`${config.username}:${config.password}`).toString('base64');
532
- fetchOptions.headers = {
533
- ...fetchOptions.headers,
534
- 'Authorization': `Basic ${auth}`,
535
- };
536
- }
537
- // Download image
538
- const response = await fetch(imageUrl, fetchOptions);
539
- if (!response.ok) {
540
- console.warn(`⚠️ Failed to download image: ${imageUrl} (Status: ${response.status})`);
541
- return null;
542
- }
543
- // Get image as buffer
544
- const arrayBuffer = await response.arrayBuffer();
545
- const buffer = Buffer.from(arrayBuffer);
546
- // Write to file
547
- fs.writeFileSync(localPath, buffer);
548
- return publicPath;
549
- }
550
- catch (error) {
551
- console.warn(`⚠️ Error downloading image ${imageUrl}:`, error instanceof Error ? error.message : String(error));
552
- return null;
553
- }
554
- }
555
- /**
556
- * Batch download images with concurrency control
557
- */
558
- async function downloadImagesBatch(imageUrls, config, concurrency = 5) {
559
- const results = new Map();
560
- const uniqueUrls = Array.from(new Set(imageUrls)); // Deduplicate
561
- // Process in batches
562
- for (let i = 0; i < uniqueUrls.length; i += concurrency) {
563
- const batch = uniqueUrls.slice(i, i + concurrency);
564
- const batchResults = await Promise.all(batch.map(url => downloadImageToPublic(url, config).then(path => ({ url, path }))));
565
- batchResults.forEach(({ url, path }) => {
566
- results.set(url, path);
567
- });
568
- }
569
- return results;
570
- }
571
-
572
469
  /**
573
470
  * @license GPL-3.0-or-later
574
471
  *
@@ -588,233 +485,8 @@ async function downloadImagesBatch(imageUrls, config, concurrency = 5) {
588
485
  // WordPress Static Data Generator
589
486
  class WordPressGenerator {
590
487
  constructor(config) {
591
- this.imageDownloadCache = new Map();
592
488
  this.config = config;
593
489
  }
594
- /**
595
- * Check if an image has Cloudflare URL available
596
- */
597
- hasCloudflareImage(item) {
598
- return !!(item?.cloudflare_image ||
599
- item?.cloudflareImage ||
600
- item?._embedded?.['wp:featuredmedia']?.[0]?.cloudflare_image ||
601
- item?._embedded?.['wp:featuredmedia']?.[0]?.cloudflareImage);
602
- }
603
- /**
604
- * Extract image URL from various sources (media item, featured media, etc.)
605
- */
606
- extractImageUrl(item) {
607
- // Check for Cloudflare image first
608
- if (item?.cloudflare_image)
609
- return item.cloudflare_image;
610
- if (item?.cloudflareImage)
611
- return item.cloudflareImage;
612
- // Check embedded featured media
613
- const featuredMedia = item?._embedded?.['wp:featuredmedia']?.[0];
614
- if (featuredMedia?.cloudflare_image)
615
- return featuredMedia.cloudflare_image;
616
- if (featuredMedia?.cloudflareImage)
617
- return featuredMedia.cloudflareImage;
618
- // Fallback to source_url
619
- if (item?.source_url)
620
- return item.source_url;
621
- if (featuredMedia?.source_url)
622
- return featuredMedia.source_url;
623
- return null;
624
- }
625
- /**
626
- * Process images in blocks recursively
627
- */
628
- extractImageUrlsFromBlocks(blocks) {
629
- const urls = [];
630
- const processBlock = (block) => {
631
- if (!block || typeof block !== 'object')
632
- return;
633
- // Check block attributes for image URLs
634
- if (block.attributes) {
635
- const attrs = block.attributes;
636
- // core/image block
637
- if (attrs.url)
638
- urls.push(attrs.url);
639
- if (attrs.mediaUrl)
640
- urls.push(attrs.mediaUrl);
641
- // core/cover block
642
- if (attrs.url)
643
- urls.push(attrs.url);
644
- if (attrs.backgroundImage)
645
- urls.push(attrs.backgroundImage);
646
- // core/media-text block
647
- if (attrs.mediaUrl)
648
- urls.push(attrs.mediaUrl);
649
- if (attrs.mediaLink)
650
- urls.push(attrs.mediaLink);
651
- // core/gallery block
652
- if (Array.isArray(attrs.images)) {
653
- attrs.images.forEach((img) => {
654
- if (img.url)
655
- urls.push(img.url);
656
- if (img.source_url)
657
- urls.push(img.source_url);
658
- });
659
- }
660
- }
661
- // Process inner blocks recursively
662
- if (Array.isArray(block.innerBlocks)) {
663
- block.innerBlocks.forEach(processBlock);
664
- }
665
- };
666
- blocks.forEach(processBlock);
667
- return urls;
668
- }
669
- /**
670
- * Process and download images if needed
671
- * Downloads images when Cloudflare images are not available (works in both direct and proxy modes)
672
- */
673
- async processImages(items, itemType, outputDir) {
674
- // Collect all image URLs that need downloading
675
- const imageUrls = [];
676
- // Process media items
677
- if (itemType === 'media') {
678
- items.forEach((item) => {
679
- if (!this.hasCloudflareImage(item)) {
680
- const url = this.extractImageUrl(item);
681
- if (url && !url.includes('imagedelivery.net')) {
682
- imageUrls.push(url);
683
- }
684
- }
685
- });
686
- }
687
- // Process posts/pages (featured media and block content)
688
- if (itemType === 'posts' || itemType === 'pages') {
689
- items.forEach((item) => {
690
- // Featured media
691
- const featuredMedia = item?._embedded?.['wp:featuredmedia']?.[0];
692
- if (featuredMedia && !this.hasCloudflareImage(featuredMedia)) {
693
- const url = this.extractImageUrl(featuredMedia);
694
- if (url && !url.includes('imagedelivery.net')) {
695
- imageUrls.push(url);
696
- }
697
- }
698
- // Block content images
699
- if (Array.isArray(item.blocks)) {
700
- const blockUrls = this.extractImageUrlsFromBlocks(item.blocks);
701
- blockUrls.forEach(url => {
702
- if (url && !url.includes('imagedelivery.net') && !url.startsWith('/images/')) {
703
- imageUrls.push(url);
704
- }
705
- });
706
- }
707
- });
708
- }
709
- if (imageUrls.length === 0) {
710
- return;
711
- }
712
- console.log(`📥 Downloading ${imageUrls.length} image(s) for ${itemType}...`);
713
- // Download images
714
- const downloadConfig = {
715
- outputDir,
716
- username: this.config.username,
717
- password: this.config.password,
718
- timeout: 30000,
719
- };
720
- const downloadResults = await downloadImagesBatch(imageUrls, downloadConfig, 5);
721
- // Cache results
722
- downloadResults.forEach((path, url) => {
723
- this.imageDownloadCache.set(url, path);
724
- });
725
- const successCount = Array.from(downloadResults.values()).filter(p => p !== null).length;
726
- console.log(`✅ Downloaded ${successCount}/${imageUrls.length} image(s) for ${itemType}`);
727
- }
728
- /**
729
- * Replace WordPress image URLs with local paths in an item
730
- */
731
- replaceImageUrls(item, itemType) {
732
- const processed = { ...item };
733
- // Process media items
734
- if (itemType === 'media') {
735
- if (!this.hasCloudflareImage(processed)) {
736
- const originalUrl = this.extractImageUrl(processed);
737
- if (originalUrl) {
738
- const localPath = this.imageDownloadCache.get(originalUrl);
739
- if (localPath) {
740
- processed.source_url = localPath;
741
- if (processed.media_details?.sizes) {
742
- // Update sizes URLs
743
- Object.keys(processed.media_details.sizes).forEach(size => {
744
- const sizeData = processed.media_details.sizes[size];
745
- if (sizeData.source_url) {
746
- const sizeLocalPath = this.imageDownloadCache.get(sizeData.source_url);
747
- if (sizeLocalPath) {
748
- sizeData.source_url = sizeLocalPath;
749
- }
750
- }
751
- });
752
- }
753
- }
754
- }
755
- }
756
- }
757
- // Process posts/pages
758
- if (itemType === 'posts' || itemType === 'pages') {
759
- // Featured media
760
- if (processed._embedded?.['wp:featuredmedia']?.[0]) {
761
- const featuredMedia = { ...processed._embedded['wp:featuredmedia'][0] };
762
- if (!this.hasCloudflareImage(featuredMedia)) {
763
- const originalUrl = this.extractImageUrl(featuredMedia);
764
- if (originalUrl) {
765
- const localPath = this.imageDownloadCache.get(originalUrl);
766
- if (localPath) {
767
- featuredMedia.source_url = localPath;
768
- processed._embedded['wp:featuredmedia'] = [featuredMedia];
769
- }
770
- }
771
- }
772
- }
773
- // Block content
774
- if (Array.isArray(processed.blocks)) {
775
- const replaceBlockUrls = (block) => {
776
- const processedBlock = { ...block };
777
- if (processedBlock.attributes) {
778
- const attrs = { ...processedBlock.attributes };
779
- // Replace various image URL fields
780
- ['url', 'mediaUrl', 'backgroundImage', 'mediaLink'].forEach(field => {
781
- if (attrs[field]) {
782
- const localPath = this.imageDownloadCache.get(attrs[field]);
783
- if (localPath) {
784
- attrs[field] = localPath;
785
- }
786
- }
787
- });
788
- // Handle gallery images
789
- if (Array.isArray(attrs.images)) {
790
- attrs.images = attrs.images.map((img) => {
791
- const processedImg = { ...img };
792
- if (img.url) {
793
- const localPath = this.imageDownloadCache.get(img.url);
794
- if (localPath)
795
- processedImg.url = localPath;
796
- }
797
- if (img.source_url) {
798
- const localPath = this.imageDownloadCache.get(img.source_url);
799
- if (localPath)
800
- processedImg.source_url = localPath;
801
- }
802
- return processedImg;
803
- });
804
- }
805
- processedBlock.attributes = attrs;
806
- }
807
- // Process inner blocks
808
- if (Array.isArray(processedBlock.innerBlocks)) {
809
- processedBlock.innerBlocks = processedBlock.innerBlocks.map(replaceBlockUrls);
810
- }
811
- return processedBlock;
812
- };
813
- processed.blocks = processed.blocks.map(replaceBlockUrls);
814
- }
815
- }
816
- return processed;
817
- }
818
490
  async generateStaticData() {
819
491
  const client = new WordPressClient(this.config);
820
492
  console.log('🚀 Starting WordPress static data generation...');
@@ -830,7 +502,7 @@ class WordPressGenerator {
830
502
  };
831
503
  console.log(`📋 Fetching post types: ${postTypes.join(', ')}`);
832
504
  console.log(`⚙️ Settings: maxItems=${fetchParams.per_page}, includeEmbedded=${fetchParams._embed}`);
833
- // Fetch WordPress Settings (Reading Settings + Site Branding)
505
+ // Fetch WordPress Settings (Reading Settings + Site Branding + Theme Styles)
834
506
  let frontPage;
835
507
  let settingsPageId;
836
508
  let siteSettings;
@@ -866,53 +538,24 @@ class WordPressGenerator {
866
538
  console.log(`✅ Site name: ${siteSettings.site_name}`);
867
539
  }
868
540
  }
869
- }
870
- catch (error) {
871
- console.warn('⚠️ Could not fetch WordPress settings, will use fallback logic:', error);
872
- }
873
- // Fetch Theme Styles (Typography, Colors, Backgrounds, Shadows, Layout)
874
- try {
875
- console.log('🎨 Fetching Theme Styles...');
876
- const styles = await client.getThemeStyles();
877
- if (styles && (styles.typography || styles.colors || styles.backgrounds || styles.shadows || styles.layout || styles.theme_palette)) {
878
- themeStyles = styles;
541
+ // Extract theme styles
542
+ if (settings.theme_styles) {
543
+ themeStyles = settings.theme_styles;
879
544
  console.log(`✅ Theme styles found:`, {
880
- typography: !!styles.typography,
881
- colors: !!styles.colors,
882
- theme_palette: !!styles.theme_palette,
883
- theme_palette_keys: styles.theme_palette ? Object.keys(styles.theme_palette) : [],
884
- backgrounds: !!styles.backgrounds,
885
- shadows: !!styles.shadows,
886
- layout: !!styles.layout,
545
+ hasTypography: !!themeStyles.typography,
546
+ hasColors: !!themeStyles.colors,
547
+ hasLayout: !!themeStyles.layout,
887
548
  });
888
- if (styles.theme_palette) {
889
- console.log(`🎨 Theme palette colors:`, styles.theme_palette);
890
- }
549
+ }
550
+ else {
551
+ console.log('⚠️ No theme_styles found in settings response');
891
552
  }
892
553
  }
893
554
  catch (error) {
894
- console.warn('⚠️ Could not fetch theme styles, will use defaults:', error);
555
+ console.warn('⚠️ Could not fetch WordPress settings, will use fallback logic:', error);
895
556
  }
896
557
  // Fetch standard post types
897
558
  const data = await client.getAllData(fetchParams);
898
- // Determine output directory for images (public/images relative to output file)
899
- const outputDir = path.join(process.cwd(), path.dirname(this.config.outputPath), 'images');
900
- // Process and download images if needed (when Cloudflare images are not available)
901
- console.log('📸 Processing images for fallback download...');
902
- // Process media items
903
- if (data.media && data.media.length > 0) {
904
- await this.processImages(data.media, 'media', outputDir);
905
- data.media = data.media.map(item => this.replaceImageUrls(item, 'media'));
906
- }
907
- // Process posts
908
- if (data.posts && data.posts.length > 0) {
909
- await this.processImages(data.posts, 'posts', outputDir);
910
- data.posts = data.posts.map(item => this.replaceImageUrls(item, 'posts'));
911
- }
912
- // Process pages (will be processed again after blocks are fetched)
913
- if (data.pages && data.pages.length > 0) {
914
- await this.processImages(data.pages, 'pages', outputDir);
915
- }
916
559
  // Determine front page if not already set from settings
917
560
  if (!frontPage) {
918
561
  if (settingsPageId) {
@@ -1040,31 +683,7 @@ class WordPressGenerator {
1040
683
  }
1041
684
  }
1042
685
  }
1043
- // Process images in blocks if needed
1044
- let processedPage = { ...p, blocks };
1045
- if (blocks.length > 0) {
1046
- // Extract and download any new images from blocks
1047
- const blockUrls = this.extractImageUrlsFromBlocks(blocks);
1048
- const newUrls = blockUrls.filter(url => url &&
1049
- !url.includes('imagedelivery.net') &&
1050
- !url.startsWith('/images/') &&
1051
- !this.imageDownloadCache.has(url));
1052
- if (newUrls.length > 0) {
1053
- const downloadConfig = {
1054
- outputDir,
1055
- username: this.config.username,
1056
- password: this.config.password,
1057
- timeout: 30000,
1058
- };
1059
- const downloadResults = await downloadImagesBatch(newUrls, downloadConfig, 5);
1060
- downloadResults.forEach((path, url) => {
1061
- this.imageDownloadCache.set(url, path);
1062
- });
1063
- }
1064
- // Replace URLs in blocks
1065
- processedPage = this.replaceImageUrls(processedPage, 'pages');
1066
- }
1067
- return processedPage;
686
+ return { ...p, blocks };
1068
687
  })),
1069
688
  media: data.media,
1070
689
  categories: data.categories,