@marvalt/wadapter 2.3.44 â 2.3.46
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/client/wordpress-client.d.ts +2 -1
- package/dist/client/wordpress-client.d.ts.map +1 -1
- package/dist/generators/wordpress/wordpress-generator.d.ts.map +1 -1
- package/dist/generators.cjs +437 -61
- package/dist/generators.cjs.map +1 -1
- package/dist/generators.esm.js +437 -61
- package/dist/generators.esm.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.esm.js +98 -2
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +98 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -116,7 +116,8 @@ export declare class WordPressClient {
|
|
|
116
116
|
}>>;
|
|
117
117
|
/**
|
|
118
118
|
* Fetch a specific navigation menu with its items
|
|
119
|
-
*
|
|
119
|
+
* Handles both menu term IDs and wp_navigation post IDs
|
|
120
|
+
* @param menuId Menu ID (can be menu term ID or wp_navigation post ID)
|
|
120
121
|
* @returns Menu data with hierarchical items
|
|
121
122
|
*/
|
|
122
123
|
getMenu(menuId: number): Promise<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wordpress-client.d.ts","sourceRoot":"","sources":["../../src/client/wordpress-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,aAAa,EAAE,aAAa,EAAE,cAAc,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAE1J,qBAAa,eAAe;IAC1B,OAAO,CAAC,MAAM,CAAkB;gBAEpB,MAAM,EAAE,eAAe;YAIrB,WAAW;IAwGzB,OAAO,CAAC,UAAU;IASlB;;;;OAIG;IACG,QAAQ,CAAC,MAAM,GAAE,oBAAyB,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAIrE,OAAO,CAAC,EAAE,EAAE,MAAM,G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1B,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"}
|
|
@@ -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,MAAM,+BAA+B,CAAC;AAElE,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;IACrB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,eAAe;IAC9B,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE;QACX,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;IACF,aAAa,CAAC,EAAE,YAAY,CAAC;IAC7B,MAAM,CAAC,EAAE;QACP,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAA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ACtB,CAAC;QACF,MAAM,CAAC,EAAE;YACP,OAAO,CAAC,EAAE,MAAM,CAAC;YACjB,SAAS,CAAC,EAAE,MAAM,CAAC;YACnB,IAAI,CAAC,EAAE,MAAM,CAAC;YACd,OAAO,CAAC,EAAE,MAAM,CAAC;YACjB,UAAU,CAAC,EAAE,MAAM,CAAC;SACrB,CAAC;QACF,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACvC,MAAM,CAAC,EAAE;YACP,mBAAmB,CAAC,EAAE,MAAM,CAAC;YAC7B,wBAAwB,CAAC,EAAE,MAAM,CAAC;YAClC,eAAe,CAAC,EAAE,MAAM,CAAC;SAC1B,CAAC;QACF,WAAW,CAAC,EAAE;YACZ,KAAK,CAAC,EAAE,MAAM,CAAC;YACf,MAAM,CAAC,EAAE,MAAM,CAAC;YAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;YAClB,IAAI,CAAC,EAAE,MAAM,CAAC;SACf,CAAC;QACF,OAAO,CAAC,EAAE;YACR,UAAU,CAAC,EAAE,MAAM,CAAC;YACpB,WAAW,CAAC,EAAE,MAAM,CAAC;SACtB,CAAC;KACH,CAAC;IACF,MAAM,EAAE;QACN,WAAW,EAAE,MAAM,CAAC;QACpB,aAAa,EAAE,MAAM,CAAC;QACtB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE;YACzB,SAAS,EAAE,MAAM,CAAC;YAClB,gBAAgB,EAAE,OAAO,CAAC;YAC1B,OAAO,CAAC,EAAE,MAAM,CAAC;YACjB,KAAK,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;YACvB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;SACvB,CAAC,CAAC;KACJ,CAAC;IACF,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;
|
|
1
|
+
{"version":3,"file":"wordpress-generator.d.ts","sourceRoot":"","sources":["../../../src/generators/wordpress/wordpress-generator.ts"],"names":[],"mappings":"AAAA;;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E;YACZ,KAAK,CAAC,EAAE,MAAM,CAAC;YACf,MAAM,CAAC,EAAE,MAAM,CAAC;YAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;YAClB,IAAI,CAAC,EAAE,MAAM,CAAC;SACf,CAAC;QACF,OAAO,CAAC,EAAE;YACR,UAAU,CAAC,EAAE,MAAM,CAAC;YACpB,WAAW,CAAC,EAAE,MAAM,CAAC;SACtB,CAAC;KACH,CAAC;IACF,MAAM,EAAE;QACN,WAAW,EAAE,MAAM,CAAC;QACpB,aAAa,EAAE,MAAM,CAAC;QACtB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE;YACzB,SAAS,EAAE,MAAM,CAAC;YAClB,gBAAgB,EAAE,OAAO,CAAC;YAC1B,OAAO,CAAC,EAAE,MAAM,CAAC;YACjB,KAAK,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;YACvB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;SACvB,CAAC,CAAC;KACJ,CAAC;IACF,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AA0VD,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,MAAM,CAA2B;gBAE7B,MAAM,EAAE,wBAAwB;IAItC,kBAAkB,IAAI,OAAO,CAAC,eAAe,CAAC;IAmjBpD,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"}
|
package/dist/generators.cjs
CHANGED
|
@@ -289,11 +289,107 @@ class WordPressClient {
|
|
|
289
289
|
}
|
|
290
290
|
/**
|
|
291
291
|
* Fetch a specific navigation menu with its items
|
|
292
|
-
*
|
|
292
|
+
* Handles both menu term IDs and wp_navigation post IDs
|
|
293
|
+
* @param menuId Menu ID (can be menu term ID or wp_navigation post ID)
|
|
293
294
|
* @returns Menu data with hierarchical items
|
|
294
295
|
*/
|
|
295
296
|
async getMenu(menuId) {
|
|
296
|
-
|
|
297
|
+
console.log(`đ [WordPressClient] Fetching menu ID ${menuId}...`);
|
|
298
|
+
try {
|
|
299
|
+
// First try the custom endpoint (handles both menu terms and wp_navigation posts)
|
|
300
|
+
console.log(` â Trying endpoint: /wp-custom/v1/menus/${menuId}`);
|
|
301
|
+
const result = await this.makeRequest(`/wp-custom/v1/menus/${menuId}`);
|
|
302
|
+
console.log(` â
Successfully fetched menu ID ${menuId} as menu term: ${result.name}`);
|
|
303
|
+
return result;
|
|
304
|
+
}
|
|
305
|
+
catch (error) {
|
|
306
|
+
const errorStatus = error.status || (error.response?.status) || 'unknown';
|
|
307
|
+
const errorMessage = error.message || 'Unknown error';
|
|
308
|
+
console.log(` â Menu term fetch failed (status: ${errorStatus}): ${errorMessage}`);
|
|
309
|
+
// If 404, try fetching as wp_navigation post
|
|
310
|
+
if (errorStatus === 404 || errorMessage?.includes('404')) {
|
|
311
|
+
console.log(` â Menu ID ${menuId} not found as menu term, trying as wp_navigation post...`);
|
|
312
|
+
// Try custom endpoint first
|
|
313
|
+
try {
|
|
314
|
+
console.log(` â Trying navigation post endpoint: /wp-custom/v1/navigation/${menuId}`);
|
|
315
|
+
const navPost = await this.makeRequest(`/wp-custom/v1/navigation/${menuId}`);
|
|
316
|
+
console.log(` â
Navigation post fetched:`, {
|
|
317
|
+
id: navPost.id,
|
|
318
|
+
hasMenu: !!navPost.menu,
|
|
319
|
+
menuTermId: navPost.menu_term_id,
|
|
320
|
+
});
|
|
321
|
+
if (navPost.menu) {
|
|
322
|
+
console.log(` â
Returning menu from navigation post: ${navPost.menu.name}`);
|
|
323
|
+
return navPost.menu;
|
|
324
|
+
}
|
|
325
|
+
// If navigation post has a menu_term_id, fetch that menu
|
|
326
|
+
if (navPost.menu_term_id) {
|
|
327
|
+
console.log(` â Navigation post has menu_term_id ${navPost.menu_term_id}, fetching menu...`);
|
|
328
|
+
const menu = await this.makeRequest(`/wp-custom/v1/menus/${navPost.menu_term_id}`);
|
|
329
|
+
console.log(` â
Fetched menu from menu_term_id ${navPost.menu_term_id}: ${menu.name}`);
|
|
330
|
+
return menu;
|
|
331
|
+
}
|
|
332
|
+
else {
|
|
333
|
+
console.warn(` â ī¸ Navigation post ${menuId} has no menu_term_id and no menu data`);
|
|
334
|
+
throw new Error(`Navigation post ${menuId} has no menu_term_id and no menu data`);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
catch (navError) {
|
|
338
|
+
const navErrorStatus = navError.status || (navError.response?.status) || 'unknown';
|
|
339
|
+
const navErrorMessage = navError.message || 'Unknown error';
|
|
340
|
+
console.log(` â Navigation post fetch failed (status: ${navErrorStatus}): ${navErrorMessage}`);
|
|
341
|
+
// If custom endpoint fails, try WordPress native REST API (WordPress 6.3+)
|
|
342
|
+
if (navErrorStatus === 404 || navErrorMessage?.includes('404')) {
|
|
343
|
+
console.log(` â Custom navigation endpoint not found, trying WordPress native REST API...`);
|
|
344
|
+
try {
|
|
345
|
+
console.log(` â Trying WordPress native REST API: /wp/v2/navigation/${menuId}`);
|
|
346
|
+
// WordPress 6.3+ has native REST API for wp_navigation posts
|
|
347
|
+
const navPost = await this.makeRequest(`/wp/v2/navigation/${menuId}`);
|
|
348
|
+
console.log(` â
WordPress native navigation post fetched:`, {
|
|
349
|
+
id: navPost.id,
|
|
350
|
+
title: navPost.title?.rendered,
|
|
351
|
+
hasContent: !!navPost.content?.raw,
|
|
352
|
+
});
|
|
353
|
+
// Parse blocks from content to find menu reference
|
|
354
|
+
// The content.raw contains the block JSON
|
|
355
|
+
if (navPost.content?.raw) {
|
|
356
|
+
try {
|
|
357
|
+
const blocks = JSON.parse(navPost.content.raw);
|
|
358
|
+
console.log(` â Parsed ${Array.isArray(blocks) ? blocks.length : 'unknown'} blocks from navigation post`);
|
|
359
|
+
// Look for menu reference in blocks (this would need to be done server-side)
|
|
360
|
+
// For now, throw error to indicate menu extraction requires server-side processing
|
|
361
|
+
console.log(`âšī¸ Found wp_navigation post ${menuId}, but menu extraction requires server-side processing`);
|
|
362
|
+
throw new Error(`Menu extraction from wp_navigation post ${menuId} requires server-side processing`);
|
|
363
|
+
}
|
|
364
|
+
catch (parseError) {
|
|
365
|
+
console.log(`â ī¸ Could not parse navigation post content`);
|
|
366
|
+
throw new Error(`Could not parse navigation post content for menu ID ${menuId}`);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
else {
|
|
370
|
+
throw new Error(`wp_navigation post ${menuId} has no content to parse`);
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
catch (wpError) {
|
|
374
|
+
const wpErrorStatus = wpError.status || (wpError.response?.status) || 'unknown';
|
|
375
|
+
const wpErrorMessage = wpError.message || 'Unknown error';
|
|
376
|
+
console.error(` â WordPress native REST API also failed (status: ${wpErrorStatus}): ${wpErrorMessage}`);
|
|
377
|
+
console.error(` Full WordPress API error:`, wpError);
|
|
378
|
+
// Re-throw to ensure error is propagated
|
|
379
|
+
throw new Error(`Could not fetch menu ID ${menuId} via any method: ${wpErrorMessage}`);
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
else {
|
|
383
|
+
console.error(` â Navigation post fetch failed with non-404 error, re-throwing...`);
|
|
384
|
+
throw navError; // Re-throw navigation error
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
else {
|
|
389
|
+
console.error(` â Menu term fetch failed with non-404 error (status: ${errorStatus}), re-throwing...`);
|
|
390
|
+
throw error; // Re-throw original error
|
|
391
|
+
}
|
|
392
|
+
}
|
|
297
393
|
}
|
|
298
394
|
async getFooter(slug = 'footer', area = 'footer') {
|
|
299
395
|
return this.makeRequest(`/wp-custom/v1/footer`, { slug, area });
|
|
@@ -522,86 +618,194 @@ function addBlockFromStack(endOffset) {
|
|
|
522
618
|
/**
|
|
523
619
|
* Extract menu items from a navigation block's innerHTML (rendered HTML)
|
|
524
620
|
* WordPress renders navigation blocks, so menu items are in innerHTML as HTML
|
|
621
|
+
* This function properly handles submenus by parsing the nested <ul> structure
|
|
525
622
|
*/
|
|
526
623
|
function extractMenuFromNavigationHTML(innerHTML) {
|
|
527
624
|
if (!innerHTML)
|
|
528
625
|
return null;
|
|
529
|
-
//
|
|
530
|
-
|
|
531
|
-
|
|
626
|
+
// Find the main navigation container <ul>
|
|
627
|
+
const mainNavMatch = innerHTML.match(/<ul[^>]*class="[^"]*wp-block-navigation__container[^"]*"[^>]*>([\s\S]*?)<\/ul>/i);
|
|
628
|
+
if (!mainNavMatch) {
|
|
629
|
+
return null;
|
|
630
|
+
}
|
|
631
|
+
const mainNavContent = mainNavMatch[1];
|
|
532
632
|
const items = [];
|
|
533
|
-
let
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
finalUrl = pathname + urlObj.search + urlObj.hash;
|
|
563
|
-
// Ensure relative URL starts with /
|
|
564
|
-
if (!finalUrl.startsWith('/')) {
|
|
565
|
-
finalUrl = `/${finalUrl}`;
|
|
566
|
-
}
|
|
567
|
-
// Remove trailing slash (except for root path) to match React Router routes
|
|
568
|
-
if (finalUrl !== '/' && finalUrl.endsWith('/')) {
|
|
569
|
-
finalUrl = finalUrl.slice(0, -1);
|
|
570
|
-
}
|
|
571
|
-
}
|
|
633
|
+
let globalOrder = 0;
|
|
634
|
+
/**
|
|
635
|
+
* Parse a <li> element and extract menu item data
|
|
636
|
+
* Handles both regular links and submenus
|
|
637
|
+
*/
|
|
638
|
+
function parseMenuItem(liElement, parentId = 0, order = 0) {
|
|
639
|
+
// Extract the link
|
|
640
|
+
const linkMatch = liElement.match(/<a[^>]+class="[^"]*wp-block-navigation-item__content[^"]*"[^>]+href=["']([^"']+)["'][^>]*>[\s\S]*?<span[^>]*class="[^"]*wp-block-navigation-item__label[^"]*"[^>]*>([^<]+)<\/span>[\s\S]*?<\/a>/i);
|
|
641
|
+
if (!linkMatch) {
|
|
642
|
+
return null;
|
|
643
|
+
}
|
|
644
|
+
const url = linkMatch[1].trim();
|
|
645
|
+
const title = linkMatch[2].trim();
|
|
646
|
+
if (!title) {
|
|
647
|
+
return null;
|
|
648
|
+
}
|
|
649
|
+
// Normalize URL
|
|
650
|
+
let finalUrl = url;
|
|
651
|
+
try {
|
|
652
|
+
const urlObj = new URL(url, 'http://dummy.com'); // Use dummy base for relative URLs
|
|
653
|
+
const isAbsoluteUrl = url.startsWith('http://') || url.startsWith('https://');
|
|
654
|
+
if (isAbsoluteUrl) {
|
|
655
|
+
const pathname = urlObj.pathname;
|
|
656
|
+
const isExternal = pathname === '' || pathname === '/' ||
|
|
657
|
+
!urlObj.hostname.includes('vibunedemos.com') &&
|
|
658
|
+
!urlObj.hostname.includes('localhost') &&
|
|
659
|
+
!urlObj.hostname.includes('127.0.0.1');
|
|
660
|
+
if (isExternal) {
|
|
661
|
+
finalUrl = url;
|
|
572
662
|
}
|
|
573
663
|
else {
|
|
574
|
-
|
|
664
|
+
finalUrl = pathname + urlObj.search + urlObj.hash;
|
|
575
665
|
if (!finalUrl.startsWith('/')) {
|
|
576
666
|
finalUrl = `/${finalUrl}`;
|
|
577
667
|
}
|
|
578
|
-
// Remove trailing slash (except for root path) to match React Router routes
|
|
579
668
|
if (finalUrl !== '/' && finalUrl.endsWith('/')) {
|
|
580
669
|
finalUrl = finalUrl.slice(0, -1);
|
|
581
670
|
}
|
|
582
671
|
}
|
|
583
672
|
}
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
// Ensure relative URLs start with /
|
|
587
|
-
if (!finalUrl.startsWith('http://') && !finalUrl.startsWith('https://') && !finalUrl.startsWith('/')) {
|
|
673
|
+
else {
|
|
674
|
+
if (!finalUrl.startsWith('/')) {
|
|
588
675
|
finalUrl = `/${finalUrl}`;
|
|
589
676
|
}
|
|
590
|
-
// Remove trailing slash (except for root path) to match React Router routes
|
|
591
677
|
if (finalUrl !== '/' && finalUrl.endsWith('/')) {
|
|
592
678
|
finalUrl = finalUrl.slice(0, -1);
|
|
593
679
|
}
|
|
594
680
|
}
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
681
|
+
}
|
|
682
|
+
catch (e) {
|
|
683
|
+
if (!finalUrl.startsWith('http://') && !finalUrl.startsWith('https://') && !finalUrl.startsWith('/')) {
|
|
684
|
+
finalUrl = `/${finalUrl}`;
|
|
685
|
+
}
|
|
686
|
+
if (finalUrl !== '/' && finalUrl.endsWith('/')) {
|
|
687
|
+
finalUrl = finalUrl.slice(0, -1);
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
const itemId = globalOrder + 1;
|
|
691
|
+
globalOrder++;
|
|
692
|
+
const menuItem = {
|
|
693
|
+
id: itemId,
|
|
694
|
+
title: title,
|
|
695
|
+
url: finalUrl,
|
|
696
|
+
type: 'custom',
|
|
697
|
+
object_id: 0,
|
|
698
|
+
object: 'custom',
|
|
699
|
+
parent: parentId,
|
|
700
|
+
menu_order: order,
|
|
701
|
+
};
|
|
702
|
+
// Check if this <li> contains a submenu (<ul class="wp-block-navigation__submenu-container">)
|
|
703
|
+
const submenuMatch = liElement.match(/<ul[^>]*class="[^"]*wp-block-navigation__submenu-container[^"]*"[^>]*>([\s\S]*?)<\/ul>/i);
|
|
704
|
+
if (submenuMatch) {
|
|
705
|
+
const submenuContent = submenuMatch[1];
|
|
706
|
+
const children = [];
|
|
707
|
+
let childOrder = 0;
|
|
708
|
+
// Extract all <li> elements from the submenu
|
|
709
|
+
const submenuLiRegex = /<li[^>]*class="[^"]*wp-block-navigation-item[^"]*"[^>]*>([\s\S]*?)<\/li>/gi;
|
|
710
|
+
let submenuLiMatch;
|
|
711
|
+
while ((submenuLiMatch = submenuLiRegex.exec(submenuContent)) !== null) {
|
|
712
|
+
const childResult = parseMenuItem(submenuLiMatch[1], itemId, childOrder++);
|
|
713
|
+
if (childResult) {
|
|
714
|
+
children.push(childResult.item);
|
|
715
|
+
globalOrder = childResult.nextOrder;
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
if (children.length > 0) {
|
|
719
|
+
menuItem.children = children;
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
return { item: menuItem, nextOrder: globalOrder };
|
|
723
|
+
}
|
|
724
|
+
// Extract all top-level <li> elements from the main navigation
|
|
725
|
+
// Find all <li> tags and extract complete items, filtering by position
|
|
726
|
+
const liRegex = /<li[^>]*>/gi;
|
|
727
|
+
const allLiMatches = [];
|
|
728
|
+
// First pass: find all <li> tags and their matching </li>
|
|
729
|
+
let match;
|
|
730
|
+
while ((match = liRegex.exec(mainNavContent)) !== null) {
|
|
731
|
+
const liStart = match.index;
|
|
732
|
+
let depth = 0;
|
|
733
|
+
let j = liStart;
|
|
734
|
+
while (j < mainNavContent.length) {
|
|
735
|
+
if (mainNavContent.substr(j, 3) === '<li' && /[>\s\n\t]/.test(mainNavContent[j + 3] || '')) {
|
|
736
|
+
depth++;
|
|
737
|
+
}
|
|
738
|
+
else if (mainNavContent.substr(j, 5) === '</li>') {
|
|
739
|
+
depth--;
|
|
740
|
+
if (depth === 0) {
|
|
741
|
+
allLiMatches.push({ start: liStart, end: j + 5 });
|
|
742
|
+
break;
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
j++;
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
// Second pass: filter to only top-level items (not inside submenu containers)
|
|
749
|
+
// Build a map of submenu container ranges
|
|
750
|
+
const submenuRanges = [];
|
|
751
|
+
const submenuContainerRegex = /<ul[^>]*class="[^"]*wp-block-navigation__submenu-container[^"]*"[^>]*>/gi;
|
|
752
|
+
let submenuMatch;
|
|
753
|
+
// Find all submenu containers and their matching </ul> tags
|
|
754
|
+
while ((submenuMatch = submenuContainerRegex.exec(mainNavContent)) !== null) {
|
|
755
|
+
const submenuStart = submenuMatch.index;
|
|
756
|
+
const submenuUlEnd = mainNavContent.indexOf('>', submenuStart);
|
|
757
|
+
if (submenuUlEnd === -1)
|
|
758
|
+
continue;
|
|
759
|
+
// Find matching </ul> by tracking depth
|
|
760
|
+
let ulDepth = 0;
|
|
761
|
+
let checkPos = submenuUlEnd + 1;
|
|
762
|
+
let submenuEnd = -1;
|
|
763
|
+
while (checkPos < mainNavContent.length) {
|
|
764
|
+
const ulOpen = mainNavContent.indexOf('<ul', checkPos);
|
|
765
|
+
const ulClose = mainNavContent.indexOf('</ul>', checkPos);
|
|
766
|
+
if (ulOpen !== -1 && (ulClose === -1 || ulOpen < ulClose)) {
|
|
767
|
+
ulDepth++;
|
|
768
|
+
checkPos = ulOpen + 3;
|
|
769
|
+
}
|
|
770
|
+
else if (ulClose !== -1) {
|
|
771
|
+
ulDepth--;
|
|
772
|
+
if (ulDepth === 0) {
|
|
773
|
+
submenuEnd = ulClose + 5;
|
|
774
|
+
break;
|
|
775
|
+
}
|
|
776
|
+
checkPos = ulClose + 5;
|
|
777
|
+
}
|
|
778
|
+
else {
|
|
779
|
+
break;
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
if (submenuEnd !== -1) {
|
|
783
|
+
submenuRanges.push({ start: submenuStart, end: submenuEnd });
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
// Filter <li> elements: exclude only those that are children inside submenu containers
|
|
787
|
+
// An <li> is a child (inside submenu) if: submenu's <ul> starts before <li> AND submenu's </ul> ends after <li> ends
|
|
788
|
+
// An <li> is a parent (contains submenu) if: <li> starts before submenu's <ul> (we want to include these)
|
|
789
|
+
for (const { start, end } of allLiMatches) {
|
|
790
|
+
// Check if this <li> is a child inside any submenu container
|
|
791
|
+
let isChildItem = false;
|
|
792
|
+
for (const range of submenuRanges) {
|
|
793
|
+
// If submenu <ul> starts before <li> AND submenu </ul> ends after <li> ends, then <li> is a child
|
|
794
|
+
if (range.start < start && range.end > end) {
|
|
795
|
+
isChildItem = true;
|
|
796
|
+
break;
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
// Include all items except children (children will be extracted by parseMenuItem as part of their parent)
|
|
800
|
+
if (!isChildItem) {
|
|
801
|
+
const item = mainNavContent.substring(start, end);
|
|
802
|
+
if (item.includes('wp-block-navigation-item')) {
|
|
803
|
+
const result = parseMenuItem(item, 0, items.length);
|
|
804
|
+
if (result) {
|
|
805
|
+
items.push(result.item);
|
|
806
|
+
globalOrder = result.nextOrder;
|
|
807
|
+
}
|
|
808
|
+
}
|
|
605
809
|
}
|
|
606
810
|
}
|
|
607
811
|
if (items.length === 0) {
|
|
@@ -743,6 +947,7 @@ class WordPressGenerator {
|
|
|
743
947
|
let header;
|
|
744
948
|
let footer;
|
|
745
949
|
let menuData;
|
|
950
|
+
let menus = {}; // Declare menus outside try block so it's accessible later
|
|
746
951
|
try {
|
|
747
952
|
console.log('đ Fetching WordPress Settings...');
|
|
748
953
|
const settings = await client.getSettings();
|
|
@@ -836,6 +1041,33 @@ class WordPressGenerator {
|
|
|
836
1041
|
}
|
|
837
1042
|
catch (error) {
|
|
838
1043
|
console.warn(`â ī¸ Could not fetch menu data for menu ID ${menuId}:`, error);
|
|
1044
|
+
// Fallback: Try to find menu by name (mainmenu, main-menu, Main Menu, etc.)
|
|
1045
|
+
console.log('đ Menu fetch failed, attempting to find menu by name "mainmenu"...');
|
|
1046
|
+
try {
|
|
1047
|
+
const namedMenu = await findMenuByName(client, 'mainmenu');
|
|
1048
|
+
if (namedMenu && namedMenu.items && namedMenu.items.length > 0) {
|
|
1049
|
+
menuData = namedMenu;
|
|
1050
|
+
console.log(`â
Found menu by name "mainmenu": ${namedMenu.name} (${namedMenu.items.length} items)`);
|
|
1051
|
+
}
|
|
1052
|
+
else {
|
|
1053
|
+
console.log('âšī¸ No menu found with name "mainmenu"');
|
|
1054
|
+
// Try extracting from Navigation block HTML as last resort
|
|
1055
|
+
console.log('đ Attempting to extract navigation from Navigation block innerHTML...');
|
|
1056
|
+
try {
|
|
1057
|
+
const extractedMenu = extractMenuFromNavigationBlock(navBlock);
|
|
1058
|
+
if (extractedMenu && extractedMenu.items && extractedMenu.items.length > 0) {
|
|
1059
|
+
menuData = extractedMenu;
|
|
1060
|
+
console.log(`â
Extracted navigation from Navigation block: ${extractedMenu.items.length} items`);
|
|
1061
|
+
}
|
|
1062
|
+
}
|
|
1063
|
+
catch (extractError) {
|
|
1064
|
+
console.warn('â ī¸ Error extracting navigation from Navigation block:', extractError);
|
|
1065
|
+
}
|
|
1066
|
+
}
|
|
1067
|
+
}
|
|
1068
|
+
catch (nameError) {
|
|
1069
|
+
console.warn('â ī¸ Error finding menu by name:', nameError);
|
|
1070
|
+
}
|
|
839
1071
|
}
|
|
840
1072
|
}
|
|
841
1073
|
else {
|
|
@@ -907,6 +1139,149 @@ class WordPressGenerator {
|
|
|
907
1139
|
catch (error) {
|
|
908
1140
|
console.log('â ī¸ Failed to fetch footer:', error instanceof Error ? error.message : 'Unknown error');
|
|
909
1141
|
}
|
|
1142
|
+
// Extract all menu IDs from footer blocks and fetch them for static data
|
|
1143
|
+
const allMenuIds = new Set();
|
|
1144
|
+
if (menuData && menuData.id) {
|
|
1145
|
+
allMenuIds.add(menuData.id); // Add header menu
|
|
1146
|
+
console.log(`đ Added header menu ID ${menuData.id} (${menuData.name}) to menu list`);
|
|
1147
|
+
}
|
|
1148
|
+
if (footer && footer.blocks) {
|
|
1149
|
+
let navigationBlockCount = 0;
|
|
1150
|
+
const findNavigationBlocks = (blocks, depth = 0) => {
|
|
1151
|
+
for (const block of blocks) {
|
|
1152
|
+
if (block.name === 'core/navigation') {
|
|
1153
|
+
navigationBlockCount++;
|
|
1154
|
+
console.log(`đ Found navigation block at depth ${depth}:`, {
|
|
1155
|
+
blockName: block.name,
|
|
1156
|
+
hasAttributes: !!block.attributes,
|
|
1157
|
+
attributes: block.attributes ? Object.keys(block.attributes) : [],
|
|
1158
|
+
});
|
|
1159
|
+
if (block.attributes) {
|
|
1160
|
+
const menuId = block.attributes['ref'] ||
|
|
1161
|
+
block.attributes['menuId'] ||
|
|
1162
|
+
block.attributes['menu'] ||
|
|
1163
|
+
block.attributes['navigationMenuId'] ||
|
|
1164
|
+
block.attributes['menuRef'];
|
|
1165
|
+
if (menuId) {
|
|
1166
|
+
const menuIdNum = parseInt(String(menuId));
|
|
1167
|
+
allMenuIds.add(menuIdNum);
|
|
1168
|
+
console.log(` â
Extracted menu ID ${menuIdNum} from attribute:`, {
|
|
1169
|
+
ref: block.attributes['ref'],
|
|
1170
|
+
menuId: block.attributes['menuId'],
|
|
1171
|
+
menu: block.attributes['menu'],
|
|
1172
|
+
navigationMenuId: block.attributes['navigationMenuId'],
|
|
1173
|
+
menuRef: block.attributes['menuRef'],
|
|
1174
|
+
extracted: menuIdNum,
|
|
1175
|
+
});
|
|
1176
|
+
}
|
|
1177
|
+
else {
|
|
1178
|
+
console.warn(` â ī¸ Navigation block found but no menu ID attribute detected. Available attributes:`, Object.keys(block.attributes));
|
|
1179
|
+
}
|
|
1180
|
+
}
|
|
1181
|
+
else {
|
|
1182
|
+
console.warn(` â ī¸ Navigation block found but has no attributes`);
|
|
1183
|
+
}
|
|
1184
|
+
}
|
|
1185
|
+
if (block.innerBlocks && block.innerBlocks.length > 0) {
|
|
1186
|
+
findNavigationBlocks(block.innerBlocks, depth + 1);
|
|
1187
|
+
}
|
|
1188
|
+
}
|
|
1189
|
+
};
|
|
1190
|
+
findNavigationBlocks(footer.blocks);
|
|
1191
|
+
console.log(`đ Navigation block extraction summary:`, {
|
|
1192
|
+
navigationBlocksFound: navigationBlockCount,
|
|
1193
|
+
uniqueMenuIds: allMenuIds.size,
|
|
1194
|
+
menuIds: Array.from(allMenuIds),
|
|
1195
|
+
});
|
|
1196
|
+
}
|
|
1197
|
+
else {
|
|
1198
|
+
console.log(`âšī¸ No footer blocks found or footer is empty`);
|
|
1199
|
+
}
|
|
1200
|
+
// Fetch all menus and store them in a menus object keyed by ID
|
|
1201
|
+
menus = {}; // Reset menus object (already declared above)
|
|
1202
|
+
if (menuData && menuData.id) {
|
|
1203
|
+
menus[menuData.id] = menuData;
|
|
1204
|
+
console.log(`â
Added header menu to menus object: ID ${menuData.id} (${menuData.name})`);
|
|
1205
|
+
}
|
|
1206
|
+
let fetchAttempts = 0;
|
|
1207
|
+
let fetchSuccesses = 0;
|
|
1208
|
+
let fetchFailures = 0;
|
|
1209
|
+
for (const menuId of allMenuIds) {
|
|
1210
|
+
if (!menus[menuId]) {
|
|
1211
|
+
fetchAttempts++;
|
|
1212
|
+
console.log(`đ Attempting to fetch menu ID ${menuId}... (attempt ${fetchAttempts}/${allMenuIds.size})`);
|
|
1213
|
+
try {
|
|
1214
|
+
const fetchedMenu = await client.getMenu(menuId);
|
|
1215
|
+
// Validate menu structure
|
|
1216
|
+
if (!fetchedMenu) {
|
|
1217
|
+
console.error(`â Menu ID ${menuId}: Fetched menu is null or undefined`);
|
|
1218
|
+
fetchFailures++;
|
|
1219
|
+
continue;
|
|
1220
|
+
}
|
|
1221
|
+
if (!fetchedMenu.id) {
|
|
1222
|
+
console.error(`â Menu ID ${menuId}: Fetched menu missing 'id' property:`, fetchedMenu);
|
|
1223
|
+
fetchFailures++;
|
|
1224
|
+
continue;
|
|
1225
|
+
}
|
|
1226
|
+
if (!fetchedMenu.name) {
|
|
1227
|
+
console.warn(`â ī¸ Menu ID ${menuId}: Fetched menu missing 'name' property:`, fetchedMenu);
|
|
1228
|
+
}
|
|
1229
|
+
if (!fetchedMenu.items) {
|
|
1230
|
+
console.warn(`â ī¸ Menu ID ${menuId}: Fetched menu missing 'items' property:`, fetchedMenu);
|
|
1231
|
+
}
|
|
1232
|
+
else if (!Array.isArray(fetchedMenu.items)) {
|
|
1233
|
+
console.error(`â Menu ID ${menuId}: Fetched menu 'items' is not an array:`, typeof fetchedMenu.items);
|
|
1234
|
+
fetchFailures++;
|
|
1235
|
+
continue;
|
|
1236
|
+
}
|
|
1237
|
+
// Store menu even if items array is empty (for debugging)
|
|
1238
|
+
menus[menuId] = fetchedMenu;
|
|
1239
|
+
if (fetchedMenu.items && fetchedMenu.items.length > 0) {
|
|
1240
|
+
fetchSuccesses++;
|
|
1241
|
+
console.log(`â
Fetched menu ID ${menuId}: ${fetchedMenu.name} (${fetchedMenu.items.length} items)`);
|
|
1242
|
+
}
|
|
1243
|
+
else {
|
|
1244
|
+
fetchSuccesses++; // Still count as success, just empty
|
|
1245
|
+
console.warn(`â ī¸ Menu ID ${menuId}: ${fetchedMenu.name} fetched but has no items`);
|
|
1246
|
+
}
|
|
1247
|
+
}
|
|
1248
|
+
catch (error) {
|
|
1249
|
+
fetchFailures++;
|
|
1250
|
+
const errorDetails = {
|
|
1251
|
+
message: error.message || 'Unknown error',
|
|
1252
|
+
status: error.status || 'unknown',
|
|
1253
|
+
};
|
|
1254
|
+
// Try to extract more error details
|
|
1255
|
+
if (error.response) {
|
|
1256
|
+
errorDetails.responseStatus = error.response.status;
|
|
1257
|
+
errorDetails.responseStatusText = error.response.statusText;
|
|
1258
|
+
}
|
|
1259
|
+
if (error.body) {
|
|
1260
|
+
try {
|
|
1261
|
+
errorDetails.body = typeof error.body === 'string' ? error.body : JSON.stringify(error.body);
|
|
1262
|
+
}
|
|
1263
|
+
catch (e) {
|
|
1264
|
+
errorDetails.body = 'Could not stringify error body';
|
|
1265
|
+
}
|
|
1266
|
+
}
|
|
1267
|
+
console.error(`â Could not fetch menu ID ${menuId}:`, errorDetails);
|
|
1268
|
+
console.error(` Full error object:`, error);
|
|
1269
|
+
}
|
|
1270
|
+
}
|
|
1271
|
+
else {
|
|
1272
|
+
console.log(`âšī¸ Menu ID ${menuId} already in menus object, skipping fetch`);
|
|
1273
|
+
}
|
|
1274
|
+
}
|
|
1275
|
+
// Log menu fetching summary
|
|
1276
|
+
console.log(`đ Menu fetching summary:`, {
|
|
1277
|
+
totalMenuIds: allMenuIds.size,
|
|
1278
|
+
fetchAttempts,
|
|
1279
|
+
fetchSuccesses,
|
|
1280
|
+
fetchFailures,
|
|
1281
|
+
menusInObject: Object.keys(menus).length,
|
|
1282
|
+
menuIdsInObject: Object.keys(menus).map(id => parseInt(id)),
|
|
1283
|
+
menuNames: Object.values(menus).map((m) => m.name || 'unnamed').join(', '),
|
|
1284
|
+
});
|
|
910
1285
|
// Debug: Dump all WordPress theme data in development
|
|
911
1286
|
if (process.env.NODE_ENV === 'development') {
|
|
912
1287
|
const debugData = {
|
|
@@ -985,6 +1360,7 @@ class WordPressGenerator {
|
|
|
985
1360
|
...(siteSettings && { site_settings: siteSettings }),
|
|
986
1361
|
...(header && { header: header }),
|
|
987
1362
|
...(menuData && { navigation_menu: menuData }),
|
|
1363
|
+
menus: menus, // Always include menus object, even if empty, for debugging
|
|
988
1364
|
...(footer && { footer: footer }),
|
|
989
1365
|
...(themeStyles && { theme_styles: themeStyles }),
|
|
990
1366
|
config: {
|