harlan-zw/nuxt-schema-org

[ProfilePage] Missing field "mainEntity"

davidstackio opened this issue · 1 comments

Describe the bug

Google Search Console is reporting that my ProfilePage is missing the "mainEntity" field.

See:
https://developers.google.com/search/docs/appearance/structured-data/profile-page

My code that's causing the issue:

useSchemaOrg([
  defineWebPage({
    "@type": "ProfilePage",
  }),
  definePerson({
    "@id": contributor.value._id,
    name: contributor.value.name,
    description: contributor.value.description,
    image: builder
      .image(contributor.value.image ?? "")
      .fit("min")
      .auto("format")
      .size(800, 800) // 1:1
      .url(),
    url: `${useSiteConfig().url}/contributors/${
      contributor.value.slug.current
    }`,
    sameAs: [
      contributor.value.profiles?.linkedin,
      contributor.value.profiles?.x,
      contributor.value.profiles?.website,
    ],
  }),
]);

Related issue:
#21

Reproduction

No response

System / Nuxt Info

- Operating System: Windows_NT
- Node Version:     v18.19.0
- Nuxt Version:     3.9.1
- CLI Version:      3.10.0
- Nitro Version:    2.8.1
- Package Manager:  npm@10.2.1
- Builder:          -
- User Config:      extends, modules, site, schemaOrg, sitemap, ogImage
- Runtime Modules:  @nuxtjs/sanity@1.8.3, @nuxtjs/seo@2.0.0-rc.5
- Build Modules:    -

Hi, there are a couple of issues I need to solve to make this work better.

For the time being you can do this as a workaround

useSchemaOrg([
  defineWebPage({
    "@type": "ProfilePage",
    mainEntity: definePerson({
    "@id": contributor.value._id,
    name: contributor.value.name,
    description: contributor.value.description,
    image: builder
      .image(contributor.value.image ?? "")
      .fit("min")
      .auto("format")
      .size(800, 800) // 1:1
      .url(),
    url: `${useSiteConfig().url}/contributors/${
      contributor.value.slug.current
    }`,
    sameAs: [
      contributor.value.profiles?.linkedin,
      contributor.value.profiles?.x,
      contributor.value.profiles?.website,
    ],
  }),
  }),
]);