Skip to content

Commit 595fabe

Browse files
committed
feat: add project
1 parent cbc415d commit 595fabe

File tree

3 files changed

+76
-1
lines changed

3 files changed

+76
-1
lines changed

app/[project]/page.tsx

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import ReleaseCard from '@/components/release';
2+
import { projects } from '@/projects.config';
3+
import { fetchReleases } from '@/scripts/generate-releases';
4+
import { Release } from '@/types';
5+
import fs from 'fs';
6+
import Link from 'next/link';
7+
import { notFound } from 'next/navigation';
8+
import path from 'path';
9+
10+
// 生成静态路径参数
11+
export async function generateStaticParams() {
12+
await fetchReleases()
13+
return projects.map(project => ({
14+
project: project.repo,
15+
}));
16+
}
17+
18+
interface ProjectPageProps {
19+
params: {
20+
project: string;
21+
};
22+
}
23+
24+
export default async function ProjectPage({ params }: ProjectPageProps) {
25+
const { project: repo } = await params;
26+
27+
// 查找项目信息
28+
const project = projects.find(p => p.repo === repo);
29+
30+
if (!project) {
31+
notFound();
32+
}
33+
34+
// 读取存储的 releases 数据
35+
let releases: Release[] = [];
36+
try {
37+
releases = JSON.parse(
38+
fs.readFileSync(path.join(process.cwd(), 'data', repo, 'releases.json'), 'utf8')
39+
);
40+
} catch (error) {
41+
console.error('Failed to load releases data:', error);
42+
}
43+
44+
return (
45+
<div className="container mx-auto px-4 py-8">
46+
<div className="mb-6">
47+
<Link href="/" className="text-blue-600 hover:underline flex items-center gap-1">
48+
← Back to all projects
49+
</Link>
50+
</div>
51+
52+
<h1 className="text-3xl font-bold mb-2">{project.title || project.repo}</h1>
53+
{project.description && <p className="text-gray-600 mb-8">{project.description}</p>}
54+
55+
{releases.length > 0 ? (
56+
<div className="space-y-6">
57+
{releases.map(release => (
58+
<ReleaseCard key={release.id} project={project} release={release} />
59+
))}
60+
</div>
61+
) : (
62+
<p>No releases found for this project.</p>
63+
)}
64+
</div>
65+
);
66+
}

lib/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ export function formatBytes(bytes: number): string {
1616

1717
export function cdnUrl(url: string) {
1818
url = url.replace(/^\/+/, '');
19-
return `${process.env.CDN_HOST || 'http://dl.rustfs.com/artifacts'}/${url}`;
19+
return `${process.env.CDN_HOST || 'https://dl.rustfs.com/artifacts'}/${url}`;
2020
}

projects.config.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@ export interface Project {
88
}
99

1010
export const projects: Project[] = [
11+
{
12+
repo: "s3-rustfs",
13+
title: "控制台",
14+
description: "RustFS 服务器和 GUI,支持 S3 协议的文件系统。",
15+
links: [
16+
{ label: "Source", url: "https://github.com/rustfs/s3-rustfs", icon: GithubIcon },
17+
// { label: "Latest Version", url: "https://dl.rustfs.com/s3-rustfs/latest.zip", icon: PaperclipIcon },
18+
]
19+
},
1120
{
1221
repo: "console",
1322
title: "控制台",

0 commit comments

Comments
 (0)