vuejs / vuepress

📝 Minimalistic Vue-powered static site generator
https://vuepress.vuejs.org
MIT License
22.43k stars 4.79k forks source link

When permalink is used in md, the corresponding folder is not generated in Linux environment packaging #3190

Open lxiiang opened 5 months ago

lxiiang commented 5 months ago

I dynamically set the permalink of each md in extendPageData method. The corresponding folder is not generated after packaging in Linux environment, but it is OK in windows environment

mycode extendPageData($page) { const { _filePath, regularPath path, } = $page; if (!$page.frontmatter.permalink) { const pathList = String(_filePath).split("\"); const length = pathList.length; const folderName = pathList[length - 2] || ""; let fileName = pathList[length - 1].split(".")[0]; fileName = fileName.indexOf("-") >= 0 ? fileName.split("-")[1] : fileName; const title = ${folderName}/${fileName}; let englishTitle = getEnglishName(title); // 生成 permalink $page.frontmatter.permalink = /${englishTitle}; $page.frontmatter.sidebarDepth = 0; $page.title = fileName; } },