fix(import): bring WordPress menus, settings, and custom-block images through#607
Open
mohamedmostafa58 wants to merge 2 commits intoemdash-cms:mainfrom
Open
Conversation
… through WXR imports were silently dropping content: - `nav_menu_item` and `wp_navigation` post types were marked internal and filtered out of the analyzer, so the admin UI's menu-import toggle had no server-side effect. The XML's menus are now written into `_emdash_menus` / `_emdash_menu_items`, linking items that reference imported pages by ULID and falling back to a custom URL otherwise. When a WP menu item's <title> is empty (WP uses the linked page's current title at render time), the imported label falls back to the page title rather than the raw slug. - Channel-level <title>, <description>, and base URL were parsed but never written to site settings. The admin's "Import site title" toggle is now honored; analyzer also surfaces a detected homePageSlug for themes that want to key off it. - The `core/buttons` transformer only read `attrs.url`, so classic-editor content (href lives inside the inner <a>) lost all button links. It now mirrors the `core/file` transformer's HTML href fallback. - Unknown-block fallback now extracts image URLs from `attrs.imageUrl`, `attrs.items[].url`, etc., so custom theme wrappers (hero sections, logo marquees, sliders) keep their imagery instead of silently dropping it. Images remain in standard image blocks so the media-import + URL rewrite steps handle them normally. - Execute step rewrites button URLs and inline link-mark hrefs that point back to the source WordPress host into site-relative paths, so navigation stays inside the imported site. Scoped narrowly — image asset URLs stay absolute and flow through the existing media URL rewrite.
🦋 Changeset detectedLatest commit: e2a9d1e The changes in this PR will be included in the next version bump. This PR includes changesets to release 9 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
Scope checkThis PR changes 863 lines across 9 files. Large PRs are harder to review and more likely to be closed without review. If this scope is intentional, no action needed. A maintainer will review it. If not, please consider splitting this into smaller PRs. See CONTRIBUTING.md for contribution guidelines. |
@emdash-cms/admin
@emdash-cms/auth
@emdash-cms/blocks
@emdash-cms/cloudflare
emdash
create-emdash
@emdash-cms/gutenberg-to-portable-text
@emdash-cms/x402
@emdash-cms/plugin-ai-moderation
@emdash-cms/plugin-atproto
@emdash-cms/plugin-audit-log
@emdash-cms/plugin-color
@emdash-cms/plugin-embeds
@emdash-cms/plugin-forms
@emdash-cms/plugin-webhook-notifier
commit: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Fixes several silent-drop paths in the WordPress (WXR) import so exports land with their menus, site identity, button links, and custom-theme imagery intact.
nav_menu_itemandwp_navigationare filtered out as internal post types in the analyzer, so the admin UI's "Import navigation menus" toggle has no server-side effect. Any site being imported loses its Primary/Footer/etc. menus.<channel><title>,<description>, and the base URL are parsed but never written to site settings. The admin'simportSiteTitletoggle is tracked in component state but dropped inexecuteImport().core/buttonsonly readsattrs.url. Any content authored in the classic editor or older Gutenberg keeps the URL inside the inner<a href>and the container transformer doesn't fall back to it, so buttons come through with labels but no links.imageUrl, logo marquees / sliders / carousels holding anitems[]array of image URLs, and similar patterns. The unknown-block fallback only recurses intoinnerBlocks, so any imagery declared on the wrapper's attrs silently disappears.What changed
packages/core/src/astro/routes/api/import/wordpress/analyze.tsnavMenus,tagline, and a detectedhomePageSlugon the analysis response (the admin UI's existing check againstdata.navMenusnow actually hits).packages/core/src/astro/routes/api/import/wordpress/execute.tsimportNavMenushelper — writes into_emdash_menus/_emdash_menu_items, resolvespost_typemenu items that reference imported pages to their emdash IDs, falls back to a custom URL when the target wasn't imported, and replaces same-name menus on re-import.importSiteSettingshelper — writestitle/tagline/urlviasetSiteSettings.ImportConfiggainsimportMenusandimportSiteSettingsflags (default true);ImportResultreportsmenusandsiteSettingssummaries.rewriteInternalLinkspost-pass — button URLs and inline link-mark hrefs that point at the source WordPress host are rewritten to site-relative paths. Scoped narrowly: image asset URLs, linked-image hrefs, and gallery items stay absolute and continue to flow through the existing media-URL rewrite step.packages/gutenberg-to-portable-text/src/transformers/core.tscore/buttonsfalls back to the inner<a href>whenattrs.urlis missing, mirroring the fallback already incore/file.packages/gutenberg-to-portable-text/src/transformers/index.tsblock.attrsand emits standardimageblocks for any image-shaped URLs it finds (single-image attrs anditems[].urlarray shapes), in addition to recursing into inner blocks. Emits standard image blocks so the existing media-import + URL-rewrite steps pick them up normally.packages/admin) sends theimportMenus/importSiteTitletoggle state in the import config, and types are extended to match the new response fields.