Skip to content
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

Docs: Extend exemplary usage #112

Open
ohlr opened this issue Jun 11, 2020 · 4 comments
Open

Docs: Extend exemplary usage #112

ohlr opened this issue Jun 11, 2020 · 4 comments

Comments

@ohlr
Copy link

ohlr commented Jun 11, 2020

Although quite trivial afterwards, it took me quite a while to figure out how to use this library with react-helmet.
You might consider updating the docs if not, feel free to close this.

const script = [
    {
        type: "application/ld+json",
        innerHTML: `${JSON.stringify(p)}`,
    },
];
<Helmet script={script} />
@Eyas
Copy link
Collaborator

Eyas commented Jun 12, 2020

Thanks for the suggestion! Documenting Helmet usage is a good idea. If you would like to contribute something here, I'm happy to review it!

I can whip something up otherwise

Eyas added a commit to Eyas/react-schemaorg that referenced this issue Jun 19, 2020
Originally suggested in google/schema-dts#112

Wraps returned innerHTML with safeJsonLdReplacer as well, since Helmet
will similarly just pass innerHTML as-is to dangerouslySetInnerHTML.
@Eyas
Copy link
Collaborator

Eyas commented Jun 19, 2020

I'll add some docs here, but I actually think this is a good candidate for google/react-schemaorg, which wraps this library with convenience React-specific functions.

Helmet's innerHTML can be dangerous, e.g. a string can contain '</script>', and that library takes care of serializing/escaping the JSON-LD per the standard.

@ohlr
Copy link
Author

ohlr commented Jun 19, 2020

Oh wow! I did not know there was a react wrapper...
Maybe this is something to mention in the docs

@Eyas
Copy link
Collaborator

Eyas commented Jun 19, 2020

Yeah, I'll do that soon. The standard <JsonLd> react wrapper doesn't work with Helmet, because Helmet is pretty picky about what child elements it can have. A few people have asked about this before, so getting this done once and for all would be helpful here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants