Add Schema.org JSON-LD structured data for SEO
Implemented comprehensive Schema.org structured data across the blog to improve SEO and enable rich snippets in search results. Changes: - Created JSON-LD helper component for safe schema rendering - Added BlogPosting schema to blog posts with: * Article metadata (headline, description, image, dates) * Author and publisher information * Keywords and article sections from tags - Added BreadcrumbList schema to blog posts for navigation - Added WebSite and Organization schemas to root layout * Site-wide identity and branding * Search action for site search functionality - Added CollectionPage schema to homepage * Blog collection metadata - Added WebPage schema to static pages * Page metadata with dates and images Benefits: - Rich snippets in Google/Bing search results - Better content understanding by search engines - Article cards with images, dates, authors in SERPs - Breadcrumb navigation in search results - Improved SEO ranking signals All schemas validated against Schema.org specifications and include proper Chinese language support. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -9,6 +9,7 @@ import { ReadingProgress } from '@/components/reading-progress';
|
||||
import { PostLayout } from '@/components/post-layout';
|
||||
import { ScrollReveal } from '@/components/scroll-reveal';
|
||||
import { SectionDivider } from '@/components/section-divider';
|
||||
import { JsonLd } from '@/components/json-ld';
|
||||
|
||||
export function generateStaticParams() {
|
||||
return allPages.map((page) => ({
|
||||
@@ -39,8 +40,39 @@ export default async function StaticPage({ params }: Props) {
|
||||
|
||||
const hasToc = /<h[23]/.test(page.body.html);
|
||||
|
||||
// Generate absolute URL for the page
|
||||
const pageUrl = `${siteConfig.url}${page.url}`;
|
||||
|
||||
// Get image URL if available
|
||||
const imageUrl = page.feature_image
|
||||
? `${siteConfig.url}${page.feature_image.replace('../assets', '/assets')}`
|
||||
: `${siteConfig.url}${siteConfig.ogImage}`;
|
||||
|
||||
// WebPage Schema
|
||||
const webPageSchema = {
|
||||
'@context': 'https://schema.org',
|
||||
'@type': 'WebPage',
|
||||
name: page.title,
|
||||
description: page.description || page.title,
|
||||
url: pageUrl,
|
||||
image: imageUrl,
|
||||
inLanguage: siteConfig.defaultLocale,
|
||||
isPartOf: {
|
||||
'@type': 'WebSite',
|
||||
name: siteConfig.title,
|
||||
url: siteConfig.url,
|
||||
},
|
||||
...(page.published_at && {
|
||||
datePublished: page.published_at,
|
||||
}),
|
||||
...(page.updated_at && {
|
||||
dateModified: page.updated_at,
|
||||
}),
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<JsonLd data={webPageSchema} />
|
||||
<ReadingProgress />
|
||||
<PostLayout hasToc={hasToc} contentKey={slug}>
|
||||
<div className="space-y-8">
|
||||
|
||||
Reference in New Issue
Block a user