-
Notifications
You must be signed in to change notification settings - Fork 100
Add plugin option search and replace #129
Add plugin option search and replace #129
Conversation
# Conflicts: # src/steps/source-nodes/create-nodes/process-node.js
so you're referring to this functionality in the old source plugin, correct? // Search and Replace Urls across WordPress content.
searchAndReplaceContentUrls: {
sourceUrl: "https://source-url.com",
replacementUrl: "https://replacement-url.com",
}, I like how your implementation expands on this |
@@ -799,6 +799,35 @@ const replaceNodeHtmlLinks = ({ wpUrl, nodeString, node }) => { | |||
return nodeString | |||
} | |||
|
|||
// replaces specific string with a given string from the plugin options config | |||
const findAndReplaceNodeHtmlString = ({ nodeString, node, pluginOptions }) => { | |||
if (pluginOptions?.findAndReplace?.length) { |
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.
I think we should be looking for pluginOptions?.searchAndReplace
according to the docs.
also, this would be a great place to check Array.isArray(pluginOptions?.searchAndReplace)
. However, now that we have plugin options validation, duck typing checks like these won't be as important
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.
Looking awesome all around. Do you mind if we finish it up for you?
Let's just make sure the plugin option names and doc names match up, and what's more, we just added plugin option validation, so when you pull in the upstream you can add joi validation for this option as well!
# Conflicts: # docs/plugin-options.md
@acao thanks for the review. Add the suggested change. But to be honest I never worked with this joi validation. Do you have any tips here? |
…rdpress-experimental into feat/search-and-replace # Conflicts: # docs/plugin-options.md
erm, sorry, excuse the interruption, what happened to this feature @philmuze? |
Sorry @philmuze and @munyah this PR slipped between the cracks during some internal changes at Gatsby. If you're able to open this PR on the Gatsby repo for |
Hi 👋 ,
during my upgrade gatsby-source-wordpress-experimental I missed the search and replace option from the previous version. We use this for example to replace our basic Wordpress URL with a CDN URL to serve the images from there. So with this PR I added the option to the new plugin version as well.
This solves #95.