You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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'
Example escaped title served by WordPress REST API: 'mytitle ” contains a dash'
Here is the code I expected to use in Helmet:
<Helmet title={`${post.title} } />
For the avoidance of all doubt here's my GraphQL query:
I'd really like some advice on this since I think changing the current way it's done could disrupt the way existing sites are doing things, or easily cause confusion ...
endymion1818
changed the title
gatsby-source-wordpress title field needs to be deserialized for use with react-helmet
[gatsby-source-wordpress] title field — issue with deserialization for use with react-helmet
Mar 17, 2018
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).
Description
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'
Example escaped title served by WordPress REST API: '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:
Expected result
post.title resolves to mytitle - contains a dash
Actual result
post.title resolves to mytitle ” contains a dash
What happened:
Environment
Temporary Resolution
We got around this issue by using the package
xmldom
in this way:Would it be possible to add this into a normalizer so that post.title is de-serialized?
The text was updated successfully, but these errors were encountered: