fix: hide .md extension

This commit is contained in:
hypercross 2026-02-26 14:44:54 +08:00
parent 5746249a47
commit 9bb48e0388
1 changed files with 7 additions and 2 deletions

View File

@ -62,17 +62,22 @@ export function buildFileTree(paths: string[]): FileNode[] {
for (const path of paths) {
const parts = path.split("/").filter(Boolean);
let currentPath = "";
let displayPath = "";
for (let i = 0; i < parts.length; i++) {
const part = parts[i];
const isFile = i === parts.length - 1 && part.includes(".");
currentPath += "/" + part;
// 显示路径:文件去掉 .md 扩展名
const displayPart = isFile ? part.replace(/\.md$/, "") : part;
displayPath += "/" + displayPart;
if (map.has(currentPath)) continue;
const node: FileNode = {
name: part.replace(/\.md$/, ""),
path: currentPath,
name: displayPart,
path: displayPath,
};
if (!isFile) {