Skip to content

Commit 9b47b70

Browse files
committed
fix: align profile frontmatter with schema and enhance SEO metadata
- Fix profile/index.md frontmatter to use nested i18n object format (title.zh/en, tagline.zh/en) matching content collection schema, resolving InvalidContentEntryDataError in CI build - Add OG image, Twitter large card, canonical URLs, and JSON-LD structured data to BaseLayout, BlogPost, and blog index page - Sync html[lang] attribute on language toggle for a11y/SEO - Simplify sitemap config by removing unused i18n and lastmod options
1 parent 9755a75 commit 9b47b70

6 files changed

Lines changed: 133 additions & 25 deletions

File tree

astro.config.mjs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,15 @@ export default defineConfig({
1010
react(),
1111
mdx(),
1212
sitemap({
13-
i18n: {
14-
defaultLocale: 'zh',
15-
locales: {
16-
zh: 'zh-CN',
17-
en: 'en-US',
18-
},
19-
},
2013
filter: (page) => true,
2114
customPages: [
2215
'https://eric.run.place/',
2316
'https://eric.run.place/blog/',
24-
// MermZen 子路径
2517
'https://eric.run.place/MermZen/',
26-
'https://eric.run.place/MermZen/blog/zh/',
27-
'https://eric.run.place/MermZen/blog/en/',
28-
// Windows XP
2918
'https://eric.run.place/windows-xp/',
3019
],
3120
changefreq: 'weekly',
3221
priority: 0.7,
33-
lastmod: new Date(),
3422
}),
3523
],
3624
markdown: {

src/components/Hero.astro

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,8 @@ const nameChars = profile.data.name.split('');
230230
<script is:inline>
231231
// Update hero text on language change
232232
function updateHeroText(lang) {
233+
// Sync html[lang] for accessibility and SEO
234+
document.documentElement.lang = lang === 'zh' ? 'zh-CN' : 'en';
233235
const taglineEl = document.querySelector('[data-tagline-zh]');
234236
if (taglineEl) {
235237
taglineEl.textContent = taglineEl.getAttribute(`data-tagline-${lang}`) || '';

src/content/profile/index.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
---
22
name: "Eric Cao"
3-
title_zh: "在确定性与混沌之间构建秩序"
4-
title_en: "Building order between certainty and chaos"
5-
tagline_zh: "一个喜欢折腾的开发者,在AI席卷的浪潮中努力狗刨"
6-
tagline_en: "A developer who loves tinkering, swimming hard in the sweeping tides of AI"
7-
quote_zh: ""
8-
quote_en: ""
3+
title:
4+
zh: "在确定性与混沌之间构建秩序"
5+
en: "Building order between certainty and chaos"
6+
tagline:
7+
zh: "一个喜欢折腾的开发者,在AI席卷的浪潮中努力狗刨"
8+
en: "A developer who loves tinkering, swimming hard in the sweeping tides of AI"
9+
quote:
10+
zh: ""
11+
en: ""
912
quote_author: ""
1013
avatar: ""
1114
social_links:

src/layouts/BaseLayout.astro

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,31 @@ interface Props {
1313
1414
const { profile, projects, thoughts } = Astro.props;
1515
const siteUrl = 'https://eric.run.place';
16+
const canonicalUrl = `${siteUrl}/`;
17+
const ogImage = `${siteUrl}/og-image.png`;
18+
19+
const personSchema = {
20+
"@context": "https://schema.org",
21+
"@type": "Person",
22+
"name": "Eric Cao",
23+
"url": siteUrl,
24+
"sameAs": [
25+
"https://github.com/caoergou",
26+
"https://jike.city/ergou"
27+
],
28+
"jobTitle": "Software Developer",
29+
"knowsAbout": ["Python", "TypeScript", "AI Agent", "Airflow", "Big Data", "Dify"],
30+
"email": "itsericsmail@gmail.com"
31+
};
32+
33+
const websiteSchema = {
34+
"@context": "https://schema.org",
35+
"@type": "WebSite",
36+
"name": "Eric Cao",
37+
"url": siteUrl,
38+
"description": "一个喜欢折腾的开发者,在AI席卷的浪潮中努力狗刨。",
39+
"author": { "@type": "Person", "name": "Eric Cao" }
40+
};
1641
---
1742

1843
<!DOCTYPE html>
@@ -31,23 +56,32 @@ const siteUrl = 'https://eric.run.place';
3156

3257
<!-- Open Graph / Social -->
3358
<meta property="og:type" content="website">
34-
<meta property="og:url" content={siteUrl}>
59+
<meta property="og:url" content={canonicalUrl}>
3560
<meta property="og:title" content="Eric Cao — 在AI席卷的浪潮中努力狗刨">
3661
<meta property="og:description" content="一个喜欢折腾的开发者,在AI席卷的浪潮中努力狗刨。">
62+
<meta property="og:image" content={ogImage}>
63+
<meta property="og:image:width" content="1200">
64+
<meta property="og:image:height" content="630">
65+
<meta property="og:image:alt" content="Eric Cao — 开发者个人主页">
3766
<meta property="og:site_name" content="Eric Cao">
3867
<meta property="og:locale" content="zh_CN">
3968

4069
<!-- Twitter Card -->
41-
<meta name="twitter:card" content="summary">
42-
<meta name="twitter:url" content={siteUrl}>
70+
<meta name="twitter:card" content="summary_large_image">
71+
<meta name="twitter:url" content={canonicalUrl}>
4372
<meta name="twitter:title" content="Eric Cao — 在AI席卷的浪潮中努力狗刨">
4473
<meta name="twitter:description" content="一个喜欢折腾的开发者,在AI席卷的浪潮中努力狗刨。">
74+
<meta name="twitter:image" content={ogImage}>
4575

4676
<!-- Canonical URL -->
47-
<link rel="canonical" href={siteUrl}>
77+
<link rel="canonical" href={canonicalUrl}>
4878

4979
<!-- Sitemap -->
5080
<link rel="sitemap" type="application/xml" href="/sitemap-index.xml">
81+
82+
<!-- JSON-LD Structured Data -->
83+
<script type="application/ld+json" set:html={JSON.stringify(personSchema)} />
84+
<script type="application/ld+json" set:html={JSON.stringify(websiteSchema)} />
5185
<link rel="preconnect" href="https://fonts.googleapis.com">
5286
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
5387
<link href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;700&family=Inter:wght@400;500&family=Noto+Serif+SC:wght@400&display=swap" rel="stylesheet" media="print" onload="this.media='all';this.onload=null">

src/layouts/BlogPost.astro

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,35 @@ interface Props {
33
title: string;
44
date: string;
55
description?: string;
6+
slug?: string;
67
}
78
8-
const { title, date, description } = Astro.props;
9+
const { title, date, description, slug } = Astro.props;
10+
const siteUrl = 'https://eric.run.place';
11+
const canonicalUrl = slug ? `${siteUrl}/blog/${slug}/` : `${siteUrl}/blog/`;
12+
const ogImage = `${siteUrl}/og-image.png`;
13+
const metaDescription = description || `${title} - Eric Cao 的技术文章`;
14+
15+
const articleSchema = {
16+
"@context": "https://schema.org",
17+
"@type": "BlogPosting",
18+
"headline": title,
19+
"description": metaDescription,
20+
"url": canonicalUrl,
21+
"datePublished": date,
22+
"dateModified": date,
23+
"image": ogImage,
24+
"author": {
25+
"@type": "Person",
26+
"name": "Eric Cao",
27+
"url": siteUrl
28+
},
29+
"publisher": {
30+
"@type": "Person",
31+
"name": "Eric Cao",
32+
"url": siteUrl
33+
}
34+
};
935
---
1036

1137
<!DOCTYPE html>
@@ -14,7 +40,37 @@ const { title, date, description } = Astro.props;
1440
<meta charset="UTF-8">
1541
<meta name="viewport" content="width=device-width, initial-scale=1.0">
1642
<title>{title} - Eric Cao</title>
17-
<meta name="description" content={description || title}>
43+
<meta name="description" content={metaDescription}>
44+
<meta name="author" content="Eric Cao">
45+
46+
<!-- Canonical URL -->
47+
<link rel="canonical" href={canonicalUrl}>
48+
49+
<!-- Sitemap -->
50+
<link rel="sitemap" type="application/xml" href="/sitemap-index.xml">
51+
52+
<!-- Open Graph -->
53+
<meta property="og:type" content="article">
54+
<meta property="og:url" content={canonicalUrl}>
55+
<meta property="og:title" content={`${title} - Eric Cao`}>
56+
<meta property="og:description" content={metaDescription}>
57+
<meta property="og:image" content={ogImage}>
58+
<meta property="og:image:width" content="1200">
59+
<meta property="og:image:height" content="630">
60+
<meta property="og:site_name" content="Eric Cao">
61+
<meta property="og:locale" content="zh_CN">
62+
<meta property="article:published_time" content={date}>
63+
<meta property="article:author" content="Eric Cao">
64+
65+
<!-- Twitter Card -->
66+
<meta name="twitter:card" content="summary_large_image">
67+
<meta name="twitter:title" content={`${title} - Eric Cao`}>
68+
<meta name="twitter:description" content={metaDescription}>
69+
<meta name="twitter:image" content={ogImage}>
70+
71+
<!-- JSON-LD Structured Data -->
72+
<script type="application/ld+json" set:html={JSON.stringify(articleSchema)} />
73+
1874
<link rel="preconnect" href="https://fonts.googleapis.com">
1975
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
2076
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&family=Noto+Sans+SC:wght@300;400;500&display=swap" rel="stylesheet">

src/pages/blog/index.astro

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,32 @@ import ThreeBackground from '../../components/ThreeBackground';
88
<meta charset="UTF-8">
99
<meta name="viewport" content="width=device-width, initial-scale=1.0">
1010
<title>博客 - Eric Cao</title>
11-
<meta name="description" content="分享我的思考和技术文章">
11+
<meta name="description" content="Eric Cao 的技术博客,分享 Python、AI Agent、大数据工程、系统性能优化等方向的实战经验与思考。">
12+
<meta name="author" content="Eric Cao">
13+
14+
<!-- Canonical URL -->
15+
<link rel="canonical" href="https://eric.run.place/blog/">
16+
17+
<!-- Sitemap -->
18+
<link rel="sitemap" type="application/xml" href="/sitemap-index.xml">
19+
20+
<!-- Open Graph -->
21+
<meta property="og:type" content="website">
22+
<meta property="og:url" content="https://eric.run.place/blog/">
23+
<meta property="og:title" content="博客 - Eric Cao">
24+
<meta property="og:description" content="Eric Cao 的技术博客,分享 Python、AI Agent、大数据工程、系统性能优化等方向的实战经验与思考。">
25+
<meta property="og:image" content="https://eric.run.place/og-image.png">
26+
<meta property="og:image:width" content="1200">
27+
<meta property="og:image:height" content="630">
28+
<meta property="og:site_name" content="Eric Cao">
29+
<meta property="og:locale" content="zh_CN">
30+
31+
<!-- Twitter Card -->
32+
<meta name="twitter:card" content="summary_large_image">
33+
<meta name="twitter:title" content="博客 - Eric Cao">
34+
<meta name="twitter:description" content="Eric Cao 的技术博客,分享 Python、AI Agent、大数据工程、系统性能优化等方向的实战经验与思考。">
35+
<meta name="twitter:image" content="https://eric.run.place/og-image.png">
36+
1237
<link rel="preconnect" href="https://fonts.googleapis.com">
1338
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
1439
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500&family=Noto+Sans+SC:wght@400&display=swap" rel="stylesheet" media="print" onload="this.media='all';this.onload=null">

0 commit comments

Comments
 (0)