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: 1 addition & 2 deletions next-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />
/// <reference types="next/navigation-types/compat/navigation" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/app/building-your-application/configuring/typescript for more information.
// see https://nextjs.org/docs/pages/building-your-application/configuring/typescript for more information.
6 changes: 4 additions & 2 deletions utils/mdx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ export const getAllFrontmatter = (fromPath: string) => {
.map((filePath) => {
const source = fs.readFileSync(path.join(filePath), "utf8");
const { data, content } = matter(source);

// 修复:使用 path.relative 来获取相对路径,跨平台兼容
const relativePath = path.relative(DATA_PATH, filePath);
const slug = relativePath.replace(/\.mdx$/, "").replace(/\\/g, "/"); // 统一使用正斜杠
return {
...(data as Frontmatter),
slug: filePath.replace(`${DATA_PATH}/`, "").replace(".mdx", ""),
slug,
} as Frontmatter;
})
.sort(
Expand Down