2025-11-21 13:36:06 +08:00
|
|
|
import MDXComponents from "@/components/mdx/MDXComponents";
|
|
|
|
|
import { Locale, LOCALES } from "@/i18n/routing";
|
|
|
|
|
import { constructMetadata } from "@/lib/metadata";
|
|
|
|
|
import fs from "fs/promises";
|
|
|
|
|
import { Metadata } from "next";
|
|
|
|
|
import { getTranslations } from "next-intl/server";
|
|
|
|
|
import { MDXRemote } from "next-mdx-remote-client/rsc";
|
|
|
|
|
import path from "path";
|
|
|
|
|
import remarkGfm from "remark-gfm";
|
|
|
|
|
|
|
|
|
|
const options = {
|
|
|
|
|
parseFrontmatter: true,
|
|
|
|
|
mdxOptions: {
|
|
|
|
|
remarkPlugins: [remarkGfm],
|
|
|
|
|
rehypePlugins: [],
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
2025-11-21 16:18:05 +08:00
|
|
|
async function getMDXContent(locale: string, section: string) {
|
2025-11-21 13:36:06 +08:00
|
|
|
const filePath = path.join(
|
|
|
|
|
process.cwd(),
|
|
|
|
|
"content",
|
|
|
|
|
"about",
|
2025-11-21 16:18:05 +08:00
|
|
|
section,
|
2025-11-21 13:36:06 +08:00
|
|
|
`${locale}.mdx`
|
|
|
|
|
);
|
|
|
|
|
try {
|
|
|
|
|
const content = await fs.readFile(filePath, "utf-8");
|
|
|
|
|
return content;
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error(`Error reading MDX file: ${error}`);
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type Params = Promise<{
|
|
|
|
|
locale: string;
|
|
|
|
|
}>;
|
|
|
|
|
|
|
|
|
|
type MetadataProps = {
|
|
|
|
|
params: Params;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export async function generateMetadata({
|
|
|
|
|
params,
|
|
|
|
|
}: MetadataProps): Promise<Metadata> {
|
|
|
|
|
const { locale } = await params;
|
|
|
|
|
const t = await getTranslations({ locale, namespace: "About" });
|
|
|
|
|
|
|
|
|
|
return constructMetadata({
|
|
|
|
|
page: "About",
|
|
|
|
|
title: t("title"),
|
|
|
|
|
description: t("description"),
|
|
|
|
|
locale: locale as Locale,
|
|
|
|
|
path: `/about`,
|
|
|
|
|
canonicalUrl: `/about`,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-21 16:18:05 +08:00
|
|
|
export default async function AboutPage({
|
|
|
|
|
params,
|
|
|
|
|
searchParams
|
|
|
|
|
}: {
|
|
|
|
|
params: Params;
|
|
|
|
|
searchParams: Promise<{ [key: string]: string | string[] | undefined }>;
|
|
|
|
|
}) {
|
2025-11-21 13:36:06 +08:00
|
|
|
const { locale } = await params;
|
2025-11-21 16:18:05 +08:00
|
|
|
const resolvedSearchParams = await searchParams;
|
|
|
|
|
const section = (resolvedSearchParams.section as string) || "company";
|
|
|
|
|
|
|
|
|
|
const content = await getMDXContent(locale, section);
|
2025-11-21 13:36:06 +08:00
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<article className="w-full md:w-3/5 px-2 md:px-12">
|
|
|
|
|
<MDXRemote
|
|
|
|
|
source={content}
|
|
|
|
|
components={MDXComponents}
|
|
|
|
|
options={options}
|
|
|
|
|
/>
|
|
|
|
|
</article>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export async function generateStaticParams() {
|
|
|
|
|
return LOCALES.map((locale) => ({
|
|
|
|
|
locale,
|
|
|
|
|
}));
|
2025-11-21 16:18:05 +08:00
|
|
|
}
|