--- description: 生成页面的 JSON-LD 结构化数据 argument-hint: [page-path] [schema-type] --- 为指定页面生成合适的 JSON-LD 结构化数据。支持多种 Schema.org 类型,自动检测页面内容,提供 Next.js App Router 和 Pages Router 的实现代码。 ## 功能 - ✅ 自动检测页面类型和内容 - ✅ 生成优化的 JSON-LD 结构化数据 - ✅ 支持 Next.js App Router 和 Pages Router - ✅ 提供验证工具链接 - ✅ 包含必需和推荐字段 - ✅ 支持多种 Schema.org 类型 ## 参数 - `$1` 或 `$ARGUMENTS`: 页面路径(必需) - 文件路径或路由路径 - 示例:`app/blog/post-1/page.tsx`、`/blog/post-1`、`blog/post-1` - `$2`: Schema.org 类型(可选) - 如果不提供,自动检测 - 支持类型:Article, BlogPosting, NewsArticle, Product, Organization, LocalBusiness, WebPage, FAQPage, Review, Event, Person ## 支持的 Schema 类型 ### 内容类型 **Article / BlogPosting** - 博客文章和新闻 - 包含:headline, image, datePublished, author, publisher **NewsArticle** - 新闻文章 - 额外字段:dateModified, headline, articleSection **TechArticle** - 技术教程 - 额外字段:dependencies, proficiencyLevel ### 商业类型 **Product** - 产品页面 - 包含:name, image, description, offers (price, availability) **Organization** - 组织/公司 - 包含:name, url, logo, address, contactPoint **LocalBusiness** - 本地商家 - 包含:address, telephone, openingHours, priceRange ### 页面类型 **WebPage** - 普通网页 - 包含:name, description, url **FAQPage** - FAQ 页面 - 包含:Question 和 Answer 列表 ### 互动类型 **Review** - 评论 - 包含:itemReviewed, reviewRating, author **AggregateRating** - 聚合评分 - 包含:ratingValue, reviewCount, bestRating ## 使用示例 ### 示例 1:博客文章(自动检测) ```bash /structured-data app/blog/nextjs-seo-guide/page.tsx ``` 输出: ```markdown # 结构化数据生成报告 ## 页面分析 - 页面类型:博客文章 - 检测语言:中文 - 推荐类型:BlogPosting - 标题:Next.js SEO 完全指南 - 作者:检测到或需要提供 ## 生成的 JSON-LD ```json { "@context": "https://schema.org", "@type": "BlogPosting", "headline": "Next.js SEO 完全指南:从入门到精通", "image": [ "https://yourdomain.com/images/blog/nextjs-seo-cover.jpg" ], "datePublished": "2024-01-15T08:00:00+08:00", "dateModified": "2024-01-15T08:00:00+08:00", "author": { "@type": "Person", "name": "张三" }, "publisher": { "@type": "Organization", "name": "YourBrand", "logo": { "@type": "ImageObject", "url": "https://yourdomain.com/logo.png" } }, "description": "深入了解如何在 Next.js 项目中实现 SEO 优化。涵盖元数据、结构化数据、性能优化和最佳实践。", "mainEntityOfPage": { "@type": "WebPage", "@id": "https://yourdomain.com/blog/nextjs-seo-guide" } } ``` ## Next.js App Router 实现 将以下代码添加到 `app/blog/nextjs-seo-guide/page.tsx`: ```typescript const jsonLd = { '@context': 'https://schema.org', '@type': 'BlogPosting', 'headline': 'Next.js SEO 完全指南:从入门到精通', 'image': [ 'https://yourdomain.com/images/blog/nextjs-seo-cover.jpg' ], 'datePublished': '2024-01-15T08:00:00+08:00', 'dateModified': '2024-01-15T08:00:00+08:00', 'author': { '@type': 'Person', 'name': '张三' }, 'publisher': { '@type': 'Organization', 'name': 'YourBrand', 'logo': { '@type': 'ImageObject', 'url': 'https://yourdomain.com/logo.png' } }, 'description': '深入了解如何在 Next.js 项目中实现 SEO 优化。涵盖元数据、结构化数据、性能优化和最佳实践。', 'mainEntityOfPage': { '@type': 'WebPage', '@id': 'https://yourdomain.com/blog/nextjs-seo-guide' } } export default function Page() { return ( <>