feat: 新增SEO基础功能 (robots.txt, sitemap.xml, 404页面)
- 新增 robots.ts 生成搜索引擎爬虫指令 - 新增 sitemap.ts 动态生成站点地图(含所有项目页面) - 新增自定义 404 页面,支持中英文 - 新增 catchAll 路由捕获未匹配路径 - 更新翻译文件添加 404 页面文案
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
import { notFound } from 'next/navigation'
|
||||
|
||||
export default function CatchAllPage() {
|
||||
notFound()
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
import Link from 'next/link'
|
||||
import { getTranslations } from 'next-intl/server'
|
||||
|
||||
export default async function NotFound() {
|
||||
const t = await getTranslations('notFound')
|
||||
|
||||
return (
|
||||
<div className="min-h-[60vh] flex flex-col items-center justify-center px-4">
|
||||
<h1 className="text-6xl font-bold text-primary mb-4">404</h1>
|
||||
<p className="text-xl text-gray-600 dark:text-gray-400 mb-8">
|
||||
{t('title')}
|
||||
</p>
|
||||
<p className="text-gray-500 dark:text-gray-500 mb-8 text-center max-w-md">
|
||||
{t('description')}
|
||||
</p>
|
||||
<div className="flex gap-4">
|
||||
<Link
|
||||
href="/"
|
||||
className="px-6 py-3 bg-primary text-black font-medium hover:bg-primary/90 transition-colors"
|
||||
>
|
||||
{t('backHome')}
|
||||
</Link>
|
||||
<Link
|
||||
href="/projects"
|
||||
className="px-6 py-3 border-2 border-primary text-primary font-medium hover:bg-primary/10 transition-colors"
|
||||
>
|
||||
{t('browseProjects')}
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import { MetadataRoute } from 'next'
|
||||
|
||||
export default function robots(): MetadataRoute.Robots {
|
||||
const baseUrl = process.env.NEXT_PUBLIC_SITE_URL || 'https://agentpark.ai'
|
||||
|
||||
return {
|
||||
rules: [
|
||||
{
|
||||
userAgent: '*',
|
||||
allow: '/',
|
||||
disallow: ['/api/', '/private/'],
|
||||
},
|
||||
],
|
||||
sitemap: `${baseUrl}/sitemap.xml`,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
import { MetadataRoute } from 'next'
|
||||
import { getProjects } from '@/hooks/useProjects'
|
||||
|
||||
export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
|
||||
const baseUrl = process.env.NEXT_PUBLIC_SITE_URL || 'https://agentpark.ai'
|
||||
|
||||
// 获取所有项目
|
||||
const { projects } = await getProjects({ limit: 1000 })
|
||||
|
||||
// 静态页面
|
||||
const staticPages: MetadataRoute.Sitemap = [
|
||||
{
|
||||
url: `${baseUrl}/zh`,
|
||||
lastModified: new Date(),
|
||||
changeFrequency: 'daily',
|
||||
priority: 1,
|
||||
},
|
||||
{
|
||||
url: `${baseUrl}/en`,
|
||||
lastModified: new Date(),
|
||||
changeFrequency: 'daily',
|
||||
priority: 1,
|
||||
},
|
||||
{
|
||||
url: `${baseUrl}/zh/projects`,
|
||||
lastModified: new Date(),
|
||||
changeFrequency: 'daily',
|
||||
priority: 0.9,
|
||||
},
|
||||
{
|
||||
url: `${baseUrl}/en/projects`,
|
||||
lastModified: new Date(),
|
||||
changeFrequency: 'daily',
|
||||
priority: 0.9,
|
||||
},
|
||||
]
|
||||
|
||||
// 项目详情页(中英文)
|
||||
const projectPages: MetadataRoute.Sitemap = projects.flatMap((project) => [
|
||||
{
|
||||
url: `${baseUrl}/zh/projects/${project.slug}`,
|
||||
lastModified: project.updatedAt,
|
||||
changeFrequency: 'weekly' as const,
|
||||
priority: 0.8,
|
||||
},
|
||||
{
|
||||
url: `${baseUrl}/en/projects/${project.slug}`,
|
||||
lastModified: project.updatedAt,
|
||||
changeFrequency: 'weekly' as const,
|
||||
priority: 0.8,
|
||||
},
|
||||
])
|
||||
|
||||
return [...staticPages, ...projectPages]
|
||||
}
|
||||
+31
-1
@@ -36,7 +36,31 @@
|
||||
"browseByTagsSection": "BROWSE BY TAGS",
|
||||
"featuredProjectsSection": "FEATURED PROJECTS",
|
||||
"viewAll": "VIEW ALL",
|
||||
"viewAllProjects": "VIEW ALL PROJECTS"
|
||||
"viewAllProjects": "VIEW ALL PROJECTS",
|
||||
"insightsSection": "Site Overview",
|
||||
"statsTotalProjects": "Total Projects",
|
||||
"statsActiveProjects": "Active Projects",
|
||||
"statsArchivedProjects": "Archived Projects",
|
||||
"statsTotalTags": "Total Tags",
|
||||
"statsNewProjects7d": "New in 7 Days",
|
||||
"rankingsSection": "Project Rankings",
|
||||
"latestRankingTitle": "Latest Additions",
|
||||
"starsRankingTitle": "GitHub Stars Ranking",
|
||||
"window24h": "24H",
|
||||
"window7d": "7D",
|
||||
"window30d": "30D",
|
||||
"noLatestProjects": "No new projects in this time window",
|
||||
"noStarsProjects": "No stars data available",
|
||||
"viewAllLatest": "View all latest projects",
|
||||
"viewAllByStars": "View all by stars",
|
||||
"tagInsightsSection": "Tag Popularity & Distribution",
|
||||
"topTagsTitle": "Top Tags",
|
||||
"categoryDistributionTitle": "Category Distribution",
|
||||
"tagsUnit": "tags",
|
||||
"projectsUnit": "projects",
|
||||
"noTagData": "No tag metrics available",
|
||||
"recentTimelineSection": "Recent Additions Timeline",
|
||||
"noTimelineProjects": "No recent additions yet"
|
||||
},
|
||||
"project": {
|
||||
"backToProjects": "BACK TO PROJECTS",
|
||||
@@ -104,6 +128,12 @@
|
||||
"about": "About",
|
||||
"submitProject": "SUBMIT PROJECT"
|
||||
},
|
||||
"notFound": {
|
||||
"title": "Page Not Found",
|
||||
"description": "Sorry, the page you're looking for doesn't exist or has been moved.",
|
||||
"backHome": "Back to Home",
|
||||
"browseProjects": "Browse Projects"
|
||||
},
|
||||
"layout": {
|
||||
"announcement": "DISCOVER THE FUTURE OF AI AGENTS",
|
||||
"announcementHref": "/projects",
|
||||
|
||||
+31
-1
@@ -36,7 +36,31 @@
|
||||
"browseByTagsSection": "按标签浏览",
|
||||
"featuredProjectsSection": "精选项目",
|
||||
"viewAll": "查看全部",
|
||||
"viewAllProjects": "查看全部项目"
|
||||
"viewAllProjects": "查看全部项目",
|
||||
"insightsSection": "站点概览",
|
||||
"statsTotalProjects": "项目总数",
|
||||
"statsActiveProjects": "活跃项目",
|
||||
"statsArchivedProjects": "归档项目",
|
||||
"statsTotalTags": "标签总数",
|
||||
"statsNewProjects7d": "近7天新增",
|
||||
"rankingsSection": "项目榜单",
|
||||
"latestRankingTitle": "最新入库榜",
|
||||
"starsRankingTitle": "GitHub Stars 榜",
|
||||
"window24h": "24小时",
|
||||
"window7d": "7天",
|
||||
"window30d": "30天",
|
||||
"noLatestProjects": "该时间窗口暂无新增项目",
|
||||
"noStarsProjects": "暂无可展示的 Stars 数据",
|
||||
"viewAllLatest": "查看全部最新项目",
|
||||
"viewAllByStars": "查看全部 Stars 排序",
|
||||
"tagInsightsSection": "标签热度与分布",
|
||||
"topTagsTitle": "热门标签",
|
||||
"categoryDistributionTitle": "分类分布",
|
||||
"tagsUnit": "个标签",
|
||||
"projectsUnit": "个项目",
|
||||
"noTagData": "暂无标签统计数据",
|
||||
"recentTimelineSection": "最近新增时间线",
|
||||
"noTimelineProjects": "暂无最近新增项目"
|
||||
},
|
||||
"project": {
|
||||
"backToProjects": "返回项目列表",
|
||||
@@ -104,6 +128,12 @@
|
||||
"about": "关于",
|
||||
"submitProject": "提交项目"
|
||||
},
|
||||
"notFound": {
|
||||
"title": "页面未找到",
|
||||
"description": "抱歉,您访问的页面不存在或已被移除。",
|
||||
"backHome": "返回首页",
|
||||
"browseProjects": "浏览项目"
|
||||
},
|
||||
"layout": {
|
||||
"announcement": "发现 AI 代理的未来",
|
||||
"announcementHref": "/projects",
|
||||
|
||||
Reference in New Issue
Block a user