Skip to content

Structure is not well defined, how proper use it with schema-dts #1

@HectorLS

Description

@HectorLS

Hello, im using "react": "^16.6.0"

The sample repo code is this one (which have a syntax error):

import { Person } from "schema-dts";
import { JsonLd } from "react-schemaorg";

export function GraceHopper() {
  return <JsonLd<Person>
    item={{
      "@context": "https://schema.org",
      "@type": "Person",
      name: "Grace Hopper",
      alternateName: "Grace Brewster Murray Hopper",
      alumniOf: {
        "@type": "CollegeOrUniversity",
        name: ["Yale University", "Vassar College"]
      },
      knowsAbout: ["Compilers", "Computer Science"]
    }}/>;
}

If i use code like this all works fine

import { JsonLd } from "react-schemaorg";

export function personJsonLd() {
  const sampleData = {
    "@context": "https://schema.org",
    "@type": "Person",
    name: "Grace Hopper",
    alternateName: "Grace Brewster Murray Hopper",
    alumniOf: {
      "@type": "CollegeOrUniversity",
      name: ["Yale University", "Vassar College"]
    },
    knowsAbout: ["Compilers", "Computer Science"]
  };

  
  return <JsonLd item={sampleData}/>;
}

But as you can see in the previous code i haven't used the DTS, how can i use the schema-dts library, i didn't figure it out 😞
i have try the return like:

  return (
    <JsonLd item={sampleData}>
      <Person />
    </JsonLd>
  );

But got a bunch of console error, some light/improved example would be much appreciated 🙏🏽
Thanks in advance

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions