-
*/}
首页
@@ -93,12 +77,12 @@ export default async function Page({
新闻中心
- {typeLabel && (
+ {/* {typeLabel && (
<>
/
{typeLabel}
>
- )}
+ )} */}
@@ -111,7 +95,7 @@ export default async function Page({
return (
@@ -139,9 +123,8 @@ export default async function Page({
{"<"}
@@ -167,11 +150,10 @@ export default async function Page({
key={it}
href={`/blog?page=${it}`}
prefetch={false}
- className={`px-2.5 py-1 border rounded-sm text-sm ${
- isActive
- ? "bg-red-600 text-white border-red-600"
- : "bg-white hover:bg-gray-50"
- }`}
+ className={`px-2.5 py-1 border rounded-sm text-sm ${isActive
+ ? "bg-red-600 text-white border-red-600"
+ : "bg-white hover:bg-gray-50"
+ }`}
>
{it}
@@ -181,9 +163,8 @@ export default async function Page({
{">"}
diff --git a/app/page.tsx b/app/page.tsx
new file mode 100644
index 0000000..3892dcd
--- /dev/null
+++ b/app/page.tsx
@@ -0,0 +1,6 @@
+// 默认跳转到中文版本
+import { redirect } from 'next/navigation';
+
+export default function HomePage() {
+ redirect('/zh');
+}
\ No newline at end of file
diff --git a/components/header/HeaderLinks.tsx b/components/header/HeaderLinks.tsx
index 5c86438..6515aae 100644
--- a/components/header/HeaderLinks.tsx
+++ b/components/header/HeaderLinks.tsx
@@ -3,7 +3,6 @@
import { Link as I18nLink, usePathname, useRouter } from "@/i18n/routing";
import { cn } from "@/lib/utils";
import { HeaderLink } from "@/types/common";
-import { ExternalLink } from "lucide-react";
import { useTranslations } from "next-intl";
const HeaderLinks = () => {
@@ -17,102 +16,34 @@ const HeaderLinks = () => {
return (
{headerLinks.map((link) => {
- const isAbout = link.href === "/about";
- const isNews = link.href === "/blog";
- if (isAbout) {
- return (
-
-
- {link.name}
-
- {/* 移除触发器与菜单间的间隙,使用 pt-2 保持视觉间距但不中断 hover 区域 */}
-
-
- 友发愿景
- 产品体系
- 应用场景
- 联系方式
-
-
-
- );
- }
- if (isNews) {
- return (
-
-
- {link.name}
-
-
-
- {[
- { key: "company", label: "公司新闻" },
- { key: "experts", label: "专家访谈" },
- { key: "industry", label: "行业动态" },
- { key: "notice", label: "公告" },
- ].map((it) => (
-
- ))}
-
-
-
- );
- }
+
return (
-
- {link.name}
- {link.target && link.target === "_blank" && (
-
-
-
- )}
-
+
+
+ {link.name}
+
+ {
+ link?.children && (
+
+
+ {link.children.map((child) => (
+
+ {child.name}
+
+ ))}
+
+
+ )
+ }
+
);
})}
diff --git a/i18n/messages/zh.json b/i18n/messages/zh.json
index 28198eb..276752f 100644
--- a/i18n/messages/zh.json
+++ b/i18n/messages/zh.json
@@ -13,7 +13,33 @@
},
{
"name": "走进福安德",
- "href": "/about"
+ "href": "/about",
+ "children": [
+ {
+ "name": "公司简介",
+ "href": "/about?section=company"
+ },
+ {
+ "name": "企业文化",
+ "href": "/about?section=culture"
+ },
+ {
+ "name": "生产基地",
+ "href": "/about?section=base"
+ },
+ {
+ "name": "组织架构",
+ "href": "/about?section=organization"
+ },
+ {
+ "name": "荣誉资质",
+ "href": "/about?section=awards"
+ },
+ {
+ "name": "发展历程",
+ "href": "/about?section=history"
+ }
+ ]
},
{
"name": "产品中心",
@@ -21,7 +47,21 @@
},
{
"name": "新闻中心",
- "href": "/blog"
+ "href": "/blog",
+ "children": [
+ {
+ "name": "公告",
+ "href": "/blog?category=announce"
+ },
+ {
+ "name": "新闻",
+ "href": "/blog?category=news"
+ },
+ {
+ "name": "活动",
+ "href": "/blog?category=event"
+ }
+ ]
}
]
},
@@ -35,32 +75,32 @@
"title": "关于我们",
"links": [
{
- "href": "/about?section=company",
+ "href": "/zh/about?section=company",
"name": "公司简介",
"useA": true
},
{
- "href": "/about?section=culture",
+ "href": "/zh/about?section=culture",
"name": "企业文化",
"useA": true
},
{
- "href": "/about?section=base",
+ "href": "/zh/about?section=base",
"name": "生产基地",
"useA": true
},
{
- "href": "/about?section=organization",
+ "href": "/zh/about?section=organization",
"name": "组织架构",
"useA": true
},
{
- "href": "/about?section=awards",
+ "href": "/zh/about?section=awards",
"name": "荣誉资质",
"useA": true
},
{
- "href": "/about?section=history",
+ "href": "/zh/about?section=history",
"name": "发展历程",
"useA": true
}
diff --git a/lib/getBlogs.ts b/lib/getBlogs.ts
index 357c4c8..f4f9353 100644
--- a/lib/getBlogs.ts
+++ b/lib/getBlogs.ts
@@ -1,66 +1,92 @@
import { DEFAULT_LOCALE } from '@/i18n/routing';
import { BlogPost } from '@/types/blog';
-import fs from 'fs';
-import matter from 'gray-matter';
-import path from 'path';
-const POSTS_BATCH_SIZE = 10;
-
-export async function getPosts(locale: string = DEFAULT_LOCALE): Promise<{ posts: BlogPost[] }> {
- const postsDirectory = path.join(process.cwd(), 'blogs', locale);
-
- // is directory exist
- if (!fs.existsSync(postsDirectory)) {
- return { posts: [] };
+export async function getPosts(locale: string = DEFAULT_LOCALE, category?: string): Promise<{ posts: BlogPost[], total: number }> {
+ const Id_Map: Record
= {
+ 'announce': '1989174108560080897',
+ 'news': '1988814504336605185',
+ 'event': '1989174018231549954',
}
- let filenames = await fs.promises.readdir(postsDirectory);
- filenames = filenames.reverse();
+ let url = 'http://49.232.154.205:18081/export/article/list?pageNum=1&pageSize=10&langCode=' + locale;
+ if (category) {
+ url += '&categoryId=' + Id_Map[category || 'announce']
+ }
- let allPosts: BlogPost[] = [];
+ console.log(url);
+
+ const response = await fetch(url);
+ const data = await response.json();
+ const posts = data.rows.map((item: any) => {
+ return {
+ locale, // use locale parameter
+ title: item.title,
+ description: item.summary,
+ image: item.cover || '',
+ slug: item.articleId,
+ tags: '',
+ date: item.publishedTime,
+ // visible: data.visible || 'published',
+ pin: false,
+ content: item.content,
+ metadata: data,
+ }
+
+ }) || [];
+
+ // // is directory exist
+ // if (!fs.existsSync(postsDirectory)) {
+ // return { posts: [] };
+ // }
+
+ // let filenames = await fs.promises.readdir(postsDirectory);
+ // filenames = filenames.reverse();
+
+ // let allPosts: BlogPost[] = [];
// read file by batch
- for (let i = 0; i < filenames.length; i += POSTS_BATCH_SIZE) {
- const batchFilenames = filenames.slice(i, i + POSTS_BATCH_SIZE);
+ // for (let i = 0; i < filenames.length; i += POSTS_BATCH_SIZE) {
+ // const batchFilenames = filenames.slice(i, i + POSTS_BATCH_SIZE);
- const batchPosts: BlogPost[] = await Promise.all(
- batchFilenames.map(async (filename) => {
- const fullPath = path.join(postsDirectory, filename);
- const fileContents = await fs.promises.readFile(fullPath, 'utf8');
+ // const batchPosts: BlogPost[] = await Promise.all(
+ // batchFilenames.map(async (filename) => {
+ // const fullPath = path.join(postsDirectory, filename);
+ // const fileContents = await fs.promises.readFile(fullPath, 'utf8');
- const { data, content } = matter(fileContents);
+ // const { data, content } = matter(fileContents);
- return {
- locale, // use locale parameter
- title: data.title,
- description: data.description,
- image: data.image || '',
- slug: data.slug,
- tags: data.tags,
- date: data.date,
- visible: data.visible || 'published',
- pin: data.pin || false,
- content,
- metadata: data,
- };
- })
- );
+ // return {
+ // locale, // use locale parameter
+ // title: data.title,
+ // description: data.description,
+ // image: data.image || '',
+ // slug: data.slug,
+ // tags: data.tags,
+ // date: data.date,
+ // visible: data.visible || 'published',
+ // pin: data.pin || false,
+ // content,
+ // metadata: data,
+ // };
+ // })
+ // );
- allPosts.push(...batchPosts);
- }
+ // allPosts.push(...batchPosts);
+ // }
// filter out non-published articles
- allPosts = allPosts.filter(post => post.visible === 'published');
+ // allPosts = allPosts.filter(post => post.visible === 'published');
// sort posts by pin and date
- allPosts = allPosts.sort((a, b) => {
- if (a.pin !== b.pin) {
- return (b.pin ? 1 : 0) - (a.pin ? 1 : 0);
- }
- return new Date(b.date).getTime() - new Date(a.date).getTime();
- });
+ // allPosts = allPosts.sort((a, b) => {
+ // if (a.pin !== b.pin) {
+ // return (b.pin ? 1 : 0) - (a.pin ? 1 : 0);
+ // }
+ // return new Date(b.date).getTime() - new Date(a.date).getTime();
+ // });
return {
- posts: allPosts,
+ posts,
+ total: data.total,
};
}
\ No newline at end of file
diff --git a/types/common.ts b/types/common.ts
index b0790c7..4414075 100644
--- a/types/common.ts
+++ b/types/common.ts
@@ -4,6 +4,7 @@ export interface HeaderLink {
href: string;
target?: string;
rel?: string;
+ children?: HeaderLink[];
};
export interface FooterLink {