olsonbd/superpowers-antigravity

implementing-schema-org

Use when defining data models, creating Payload Collections, or structuring API responses - ensures strict compliance with Schema.org standards for interoperability and SEO, preventing ad-hoc naming and flattened structures

查看源码

使用方法

  1. 复制安装命令,在自己的智能体环境安装前先检查源码包。
  2. 从原始文档核对所需工具、凭据和支持的宿主。
  3. 说明输入材料与期望交付物,并对照来源检查输出。
npx skills add https://github.com/olsonbd/superpowers-antigravity --skill implementing-schema-org

开始前需了解

  • 安装不包含模型订阅、API 额度或访问文件的权限。
  • 仓库星数和安装量反映活跃情况,不等于独立质量或安全测试。
仓库原始内容

按源仓库内容呈现,保留标题、案例、代码、表格、链接以及原文引用的演示图片。

Implementing Schema.org Data Models

Overview

Schema.org is the internet's standard for structured data. Adopting it prevents "bikeshedding" over field names and ensures our data is ready for SEO, AI agents, and external integrations (like calendars) from day one.

Core Principle: If Schema.org has a standard for it, use it. Do not invent your own field names.

When to Use

  • Creating a new Collection (e.g., Venues, Events, Users)
  • Defining API responses
  • Mapping data for export

The Rules

  1. Strict Naming: Use the exact property name from Schema.org (e.g., postalCode not zip, givenName not firstName).
  2. Preserve Structure: If Schema.org defines a property as a nested Type (like address -> PostalAddress), you MUST nest it. Do not flatten it for convenience.
  3. Use Standard Types: Map your entities to the most specific Schema.org Type available (e.g., Event -> SocialEvent if applicable).

Common Mappings

Our ConceptSchema.org TypeKey Fields
VenuePlacename, address (PostalAddress), geo (GeoCoordinates), publicAccess
EventEventname, startDate, endDate, location (Place), organizer (Person/Organization)
UserPersongivenName, familyName, email, telephone

Implementation Pattern (Payload CMS)

❌ BAD: Flattened & Ad-Hoc

typescript
// Venues.ts
fields: [
  { name: "street", type: "text" }, // Violation: Flattened
  { name: "zip", type: "text" }, // Violation: Wrong name
  { name: "lat", type: "number" }, // Violation: Wrong name & flattened
];

✅ GOOD: Nested & Standard

typescript
// Venues.ts
fields: [
  {
    name: "address", // Schema.org property
    type: "group", // Preserves structure
    fields: [
      { name: "streetAddress", type: "text" },
      { name: "addressLocality", type: "text" }, // City
      { name: "addressRegion", type: "text" }, // State
      { name: "postalCode", type: "text" }, // Zip
      { name: "addressCountry", type: "text" },
    ],
  },
  {
    name: "geo",
    type: "group",
    fields: [
      { name: "latitude", type: "number" },
      { name: "longitude", type: "number" },
    ],
  },
];

JSON-LD Serialization

When exposing this data via API, simply wrap it to produce valid JSON-LD:

typescript
// Example response structure
{
  "@context": "https://schema.org",
  "@type": "Place",
  "name": venue.name,
  "address": {
    "@type": "PostalAddress",
    ...venue.address // Spread the nested group directly!
  },
  "geo": {
    "@type": "GeoCoordinates",
    ...venue.geo
  }
}

Benefit: Because we preserved the structure in the database, serialization is just a spread operator (...venue.address). No complex mapping code required.

Red Flags - STOP and Fix

  • "I'll just call it zip because it's shorter." -> STOP. Use postalCode.
  • "Nested groups are annoying to query." -> STOP. Structure matters more than convenience.
  • "I'll add a customField." -> Check Schema.org first. Is there really no standard field?

References

来自同一仓库

更多 Skills

全部 Skills