Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
[gatsby-source-wordpress] title field — issue with deserialization for use with react-helmet #4543
WordPress API returns serialized HTML, this is fine when dealing with body content, however I recently encountered an issue when trying to use react-helmet to set the post.title where the post.title contained an unescaped character.
Steps to reproduce
Example title in WordPress editor title field: 'mytitle - contains a dash'
Here is the code I expected to use in Helmet:
For the avoidance of all doubt here's my GraphQL query:
post.title resolves to mytitle - contains a dash
post.title resolves to mytitle ” contains a dash
We got around this issue by using the package
Would it be possible to add this into a normalizer so that post.title is de-serialized?
Right now I think this should be done in your project in places where it makes sense - as in your example for meta tags. Might be worth adding note about it in docs, but not sure if workaround You presented is the best one (relying on DOMParser - seems pretty heave for this).