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) {
|
for (const path of paths) {
|
||||||
const parts = path.split("/").filter(Boolean);
|
const parts = path.split("/").filter(Boolean);
|
||||||
let currentPath = "";
|
let currentPath = "";
|
||||||
|
let displayPath = "";
|
||||||
|
|
||||||
for (let i = 0; i < parts.length; i++) {
|
for (let i = 0; i < parts.length; i++) {
|
||||||
const part = parts[i];
|
const part = parts[i];
|
||||||
const isFile = i === parts.length - 1 && part.includes(".");
|
const isFile = i === parts.length - 1 && part.includes(".");
|
||||||
currentPath += "/" + part;
|
currentPath += "/" + part;
|
||||||
|
|
||||||
|
// 显示路径:文件去掉 .md 扩展名
|
||||||
|
const displayPart = isFile ? part.replace(/\.md$/, "") : part;
|
||||||
|
displayPath += "/" + displayPart;
|
||||||
|
|
||||||
if (map.has(currentPath)) continue;
|
if (map.has(currentPath)) continue;
|
||||||
|
|
||||||
const node: FileNode = {
|
const node: FileNode = {
|
||||||
name: part.replace(/\.md$/, ""),
|
name: displayPart,
|
||||||
path: currentPath,
|
path: displayPath,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!isFile) {
|
if (!isFile) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue