@@ -4,26 +4,16 @@ import type { AdvancedIndex } from "fumadocs-core/search/server";
44import type { StructuredData } from "fumadocs-core/mdx-plugins" ;
55import { source } from "@/lib/source" ;
66import { basename , extname } from "path" ;
7+ import { type PageData } from "@/app/types/doc" ;
78
89type Page = ReturnType < typeof source . getPages > [ number ] ;
910
10- /**
11- * fumadocs page.data 在构建产物里的 runtime shape。
12- * 老路径:structuredData 直接 inline;新路径:通过 load() 异步拉。
13- */
14- interface PageDataShape {
15- structuredData ?: StructuredData ;
16- load ?: ( ) => Promise < { structuredData : StructuredData } > ;
17- title ?: string ;
18- description ?: string ;
19- }
20-
2111/**
2212 * 把一个 fumadocs 页面转成 Orama 索引项(复用 fumadocs-core 默认实现逻辑),
2313 * 单独抽出来是因为我们需要分片(zh / en),用 createSearchAPI 手动传 indexes。
2414 */
2515export async function pageToIndex ( page : Page ) : Promise < AdvancedIndex > {
26- const data = page . data as PageDataShape ;
16+ const data = page . data as PageData ;
2717
2818 let structuredData : StructuredData | undefined ;
2919 if ( data . structuredData ) {
@@ -52,6 +42,6 @@ export async function pageToIndex(page: Page): Promise<AdvancedIndex> {
5242 * 翻译版 frontmatter 会声明 `lang: "en"` 且通常 `translatedFrom: "zh"`。
5343 */
5444export function isEnglishPage ( page : Page ) : boolean {
55- const lang = ( page . data as { lang ?: string } ) . lang ;
45+ const lang = ( page . data as PageData ) . lang ;
5646 return lang === "en" ;
5747}
0 commit comments