@@ -4,25 +4,9 @@ import { notFound } from 'next/navigation';
4
4
import NotFound from '@/components/docs/not-found' ;
5
5
import { createRelativeLink } from 'fumadocs-ui/mdx' ;
6
6
import { getMDXComponents } from '@/mdx-components' ;
7
- import fs from 'fs' ;
8
- import path from 'path' ;
9
7
10
- // 读取文档修改时间数据
11
- function getDocLastModifiedData ( ) : Record < string , string > {
12
- try {
13
- const dataPath = path . join ( process . cwd ( ) , 'data' , 'doc-last-modified.json' ) ;
14
-
15
- if ( ! fs . existsSync ( dataPath ) ) {
16
- return { } ;
17
- }
18
-
19
- const data = fs . readFileSync ( dataPath , 'utf8' ) ;
20
- return JSON . parse ( data ) ;
21
- } catch ( error ) {
22
- console . error ( '读取文档修改时间数据失败:' , error ) ;
23
- return { } ;
24
- }
25
- }
8
+ // 在构建时导入静态数据
9
+ import docLastModifiedData from '@/data/doc-last-modified.json' ;
26
10
27
11
export default async function Page ( {
28
12
params
@@ -32,16 +16,15 @@ export default async function Page({
32
16
const { lang, slug } = await params ;
33
17
const page = source . getPage ( slug , lang ) ;
34
18
35
- // 如果页面不存在,调用 notFound()
36
19
if ( ! page || ! page . data || ! page . file ) {
37
20
return < NotFound /> ;
38
21
}
39
22
40
23
const MDXContent = page . data . body ;
41
24
42
- // 获取文档的最后修改时间
43
- const docLastModifiedData = getDocLastModifiedData ( ) ;
44
- const filePath = `content/docs/ ${ page . file . path } ` ;
25
+ // 使用构建时导入的静态数据
26
+ const filePath = `document/content/docs/ ${ page . file . path } ` ;
27
+ // @ts -ignore
45
28
const lastModified = docLastModifiedData [ filePath ] || page . data . lastModified ;
46
29
47
30
return (
0 commit comments