Files
sage-home/lib/lines.ts
砂糖 8600a01ce4 feat: 更新产品图片和内容,优化首页展示
- 新增产品线相关图片资源
- 更新中英文产品内容中的图片引用路径
- 简化首页标题并移除应用领域板块
- 优化产品中心展示内容
- 更新公司描述信息
2026-01-29 13:27:44 +08:00

27 lines
1.1 KiB
TypeScript

import { Line } from '@/types/line';
import fs from 'fs';
import matter from 'gray-matter';
import path from 'path';
// 获取指定语言的所有车间
export async function getLines(locale: string): Promise<Line[]> {
const contentPath = path.join(process.cwd(), `content/lines/${locale}`);
console.log(contentPath);
const files = fs.readdirSync(contentPath);
const workShops: Line[] = [];
for (const file of files.map((file) => file.replace('.mdx', ''))) {
const contentPath = path.join(process.cwd(), `content/lines/${locale}/${file}.mdx`);
const fileContent = fs.readFileSync(contentPath, 'utf8');
const { data: frontmatter, content } = matter(fileContent);
workShops.push(frontmatter as Line);
}
return workShops;
}
// 获取特定车间的内容
export async function getLine(locale: string, title: string): Promise<Line> {
const contentPath = path.join(process.cwd(), `content/lines/${locale}/${title}.mdx`);
const fileContent = fs.readFileSync(contentPath, 'utf8');
const { data: frontmatter, content } = matter(fileContent);
return frontmatter as Line;
}