Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/docs/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import type { PageTree } from "fumadocs-core/server";
import { CopyTracking } from "@/app/components/CopyTracking";
import { DocsPageViewTracker } from "@/app/components/DocsPageViewTracker";
import { cookies } from "next/headers";
import { type PageData } from "@/app/types/doc";

type Locale = "zh" | "en";
type SourcePage = ReturnType<typeof source.getPages>[number];
Expand Down Expand Up @@ -77,7 +78,7 @@ function chooseVariant(variants: SourcePage[], locale: Locale): SourcePage {
const originalMatching = variants.find((p) => {
const { suffix } = stripLocaleSuffix(p.slugs);
if (suffix !== null) return false;
const lang = (p.data as { lang?: string }).lang;
const lang = (p.data as PageData).lang;
return lang === locale;
});
if (originalMatching) return originalMatching;
Expand Down
8 changes: 4 additions & 4 deletions app/sitemap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ function buildDocsEntry(page: SourcePage): MetadataRoute.Sitemap[number] {
* @returns {Date | undefined} 解析后的 Date 对象,如果找不到或无效则返回 undefined。
*/
function extractDateFromPage(page: SourcePage): Date | undefined {
// (FIX) 使用我们定义的 PageData 类型,而不是 'as' 一个匿名对象
const data = (page.data ?? {}) as PageData;
// 使用我们定义的 PageData 类型
const data = page.data as PageData;

const candidates: DateLike[] = [
data?.updatedAt,
Expand Down Expand Up @@ -183,8 +183,8 @@ function sanitizeSlugPath(slugs: string[]): string {
* @returns {boolean} 如果是草稿或隐藏,返回 true。
*/
function isDraftOrHidden(page: SourcePage): boolean {
// [BUILD 修复] 使用我们定义的 PageData 类型来代替 'any'
const d = (page.data ?? {}) as PageData;
// 使用我们定义的 PageData 类型
const d = page.data as PageData;

// 检查顶层或 'frontmatter' 嵌套下的 'draft' 或 'hidden' 标志
return !!(
Expand Down