schema-dts
schema-dts copied to clipboard
Docs: Extend exemplary usage
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} />
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
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 '', and that library takes care of serializing/escaping the JSON-LD per the standard.
Oh wow! I did not know there was a react wrapper... Maybe this is something to mention in the docs
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.