fix: hide .md extension
This commit is contained in:
parent
5746249a47
commit
9bb48e0388
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue