schema-dts icon indicating copy to clipboard operation
schema-dts copied to clipboard

Docs: Extend exemplary usage

Open ohlr opened this issue 4 years ago • 4 comments

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} />

ohlr avatar Jun 11 '20 18:06 ohlr

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 avatar Jun 12 '20 17:06 Eyas

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.

Eyas avatar Jun 19 '20 14:06 Eyas

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

ohlr avatar Jun 19 '20 17:06 ohlr

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.

Eyas avatar Jun 19 '20 17:06 Eyas