-
Notifications
You must be signed in to change notification settings - Fork 8
[CMG-698] - Issue with Wordpress Connector. Case #00044506 for Horizontal #757
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR addresses issues with the WordPress connector, specifically fixing the featured image mapping functionality and improving UI styling for log messages. The main changes include refactoring the featured image mapping to properly use the assets schema path, adding a new Pages content type schema, and updating log message styling in the UI.
- Fixes featured image mapping by using the passed assets schema path instead of global variables
- Adds complete Pages content type schema definition for WordPress migration
- Updates UI styling for log messages with a new generic class
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| upload-api/migration-wordpress/libs/content_types.js | Adds new Pages content type schema with fields for title, URL, slug, body, excerpt, featured image, date, author, and related pages |
| api/src/services/wordpress.service.ts | Refactors featured image mapping function to use passed assets schema path, simplifies post processing logic, and adds assets schema path parameter to page processing functions |
| ui/src/components/LogScreen/index.tsx | Updates notification settings to hide progress bar and adds generic-log-message CSS class to log messages |
| ui/src/components/LogScreen/MigrationLogViewer.tsx | Applies same notification and styling changes as in index.tsx |
| ui/src/components/LogScreen/index.scss | Adds CSS styling for generic-log-message class with different padding |
| .talismanrc | Updates file checksums and removes duplicate configuration entries |
| // Step 1: Resolve all references for the CURRENT post | ||
| const { postCategories, postTags, postTerms } = extractPostCategories(data["category"], referencesFilePath); | ||
| const postAuthor = extractPostAuthor(data["dc:creator"], authorsFilePath); | ||
| const jsonValue = htmlToJson(new JSDOM(data["content:encoded"].replace("//g", "").replace(/<!--?\s+\/?wp:.*?-->/g, "")).window.document.querySelector("body")); |
Copilot
AI
Aug 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The regex pattern "//g" in the replace function is incorrect. It should be /<!--.*?-->/g to properly remove HTML comments.
| const jsonValue = htmlToJson(new JSDOM(data["content:encoded"].replace("//g", "").replace(/<!--?\s+\/?wp:.*?-->/g, "")).window.document.querySelector("body")); | |
| const jsonValue = htmlToJson(new JSDOM(data["content:encoded"].replace(/<!--.*?-->/gs, "").replace(/<!--?\s+\/?wp:.*?-->/g, "")).window.document.querySelector("body")); |
| url: data["link"]?.split(blog_base_url?.split("/").filter(Boolean).pop())[1], | ||
| date: postDate, | ||
| full_description: jsonValue, | ||
| excerpt: (data["excerpt:encoded"] || "").replace("//g", "").replace(/<!--?\s+\/?wp:.*?-->/g, ""), |
Copilot
AI
Aug 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The regex pattern "//g" in the replace function is incorrect. It should be /<!--.*?-->/g to properly remove HTML comments.
| excerpt: (data["excerpt:encoded"] || "").replace("//g", "").replace(/<!--?\s+\/?wp:.*?-->/g, ""), | |
| excerpt: (data["excerpt:encoded"] || "").replace(/<!--.*?-->/gs, "").replace(/<!--?\s+\/?wp:.*?-->/g, ""), |
| // 1. Resolve references for the current item | ||
| const authorRef = extractPageAuthor(item['dc:creator'], authorsFilePath); | ||
| const parentRef = extractPageParent(item['wp:post_parent']); | ||
| const body = htmlToJson(new JSDOM(item["content:encoded"].replace("//g", "").replace(/<!--?\s+\/?wp:.*?-->/g, "")).window.document.querySelector('body')); |
Copilot
AI
Aug 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The regex pattern "//g" in the replace function is incorrect. It should be /<!--.*?-->/g to properly remove HTML comments.
| const body = htmlToJson(new JSDOM(item["content:encoded"].replace("//g", "").replace(/<!--?\s+\/?wp:.*?-->/g, "")).window.document.querySelector('body')); | |
| const body = htmlToJson(new JSDOM(item["content:encoded"].replace(/<!--.*?-->/g, "").replace(/<!--?\s+\/?wp:.*?-->/g, "")).window.document.querySelector('body')); |
| const postmetaArray = Array.isArray(post["wp:postmeta"]) ? post["wp:postmeta"] : [post["wp:postmeta"]]; | ||
|
|
||
| const assetsDetails = postmetaArray | ||
| .filter((meta) => meta["wp:meta_key"] === "_thumbnail_id") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
meta?.["wp:meta_key"]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Array.isArray(post?.["wp:postmeta"])
? post["wp:postmeta"]
: (post?.["wp:postmeta"] ? [post["wp:postmeta"]] : [])
| const postmetaArray = Array.isArray(post["wp:postmeta"]) ? post["wp:postmeta"] : [post["wp:postmeta"]]; | ||
|
|
||
| const assetsDetails = postmetaArray | ||
| .filter((meta) => meta["wp:meta_key"] === "_thumbnail_id") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
meta?.["wp:meta_key"]
| .filter(Boolean); | ||
|
|
||
| if (assetsDetails?.length > 0) { | ||
| if (assetsDetails.length > 0 && postdata[postid]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assetsDetails?.length > 0 && postdata?.[postid]
| ); | ||
| }) | ||
| .filter(Boolean); // Filter out undefined matches | ||
| .filter(Boolean); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const assetsDetails = postmetaArray
?.filter?.((meta) => meta?.["wp:meta_key"] === "_thumbnail_id")
.map((meta) => {
const attachmentid = assets_${meta?.["wp:meta_value"]};
return Object.values(assetsId)?.find(
(asset: any) => asset?.uid === attachmentid
);
})
?.filter(Boolean);
| const writePromises = []; | ||
| // This filter is good, it correctly selects only post-like items. | ||
| const filteredChunk = chunkData?.filter((item: any) => | ||
| item["wp:post_type"] !== "page" && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?.
| }; | ||
| formattedPosts[customId].publish_details = []; | ||
| } | ||
| const customId = idCorrector(`posts_${data["wp:post_id"]}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
data?.["wp:post_id"]
| const customId = idCorrector(`posts_${data["wp:post_id"]}`); | ||
|
|
||
| // Step 1: Resolve all references for the CURRENT post | ||
| const { postCategories, postTags, postTerms } = extractPostCategories(data["category"], referencesFilePath); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
data?.["category"]
or for global use if(data)
| console.info("last data"); | ||
|
|
||
| // Step 5: Add the final, complete post to the combined results | ||
| if (formattedPostWithImage && formattedPostWithImage[customId]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
formattedPostWithImage?.[customId]
Issue with Wordpress Connector. Case #00044506 for Horizontal