YunYouJun / valaxy

🌌 Next Generation Static Blog Framework (Beta) 下一代静态博客框架(支持页面/配置热重载)
https://valaxy.site
MIT License
724 stars 87 forks source link

Build 阶段:当posts下包含子文件夹会构建失败 #358

Closed zsbai closed 8 months ago

zsbai commented 8 months ago

Describe the bug

当 posts 文件夹包含子文件夹的时候,通过pnpm dev本地预览可以正常渲染,但是构建pnpm run build就会报错,我的习惯时会在posts下通过年份区分博文,下面是构建日志:

PS C:\Users\baiiylu\work\valaxy-blog> pnpm run build

> valaxy-blog@0.0.0 build C:\Users\baiiylu\work\valaxy-blog
> npm run build:ssg

> valaxy-blog@0.0.0 build:ssg
> valaxy build --ssg

o Resolve valaxy config...                                                                                  18:29:14
The CJS build of Vite's Node API is deprecated. See https://vitejs.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated for more details.
√ Resolve userValaxyConfig from C:/Users/baiiylu/work/valaxy-blog/valaxy.config.ts 1.31s                    18:29:16
√ Resolve siteConfig from C:/Users/baiiylu/work/valaxy-blog/site.config.ts 383.73ms                         18:29:16
(node:26572) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
√ Resolve valaxy.config.ts from theme(yun) 448.65ms                                                         18:29:16
√ Resolve addons from C:/Users/baiiylu/work/valaxy-blog

  🌌 Valaxy  v0.18.1

  🪐 theme   > yun
  📁 C:\Users\baiiylu\work\valaxy-blog

i use vite-ssg to do ssg build...                                                                           18:29:16

[vite-ssg] Build for client...
node_modules/.pnpm/valaxy-theme-yun@0.18.1/node_modules/valaxy-theme-yun/components/third/YunTwikoo.vue?vue&type=script&setup=true&lang.ts (19:14) "useTwikooWithOptions" is not exported by "node_modules/.pnpm/valaxy@0.18.1_@types+markdown-it@13.0.7_@unhead+shared@1.8.10_postcss@8.4.35_typescript@5.3.3_unhead@1.8.10/node_modules/valaxy/client/addons/index.ts", imported by "node_modules/.pnpm/valaxy-theme-yun@0.18.1/node_modules/valaxy-theme-yun/components/third/YunTwikoo.vue?vue&type=script&setup=true&lang.ts".
node_modules/.pnpm/valaxy-theme-yun@0.18.1/node_modules/valaxy-theme-yun/components/third/YunWaline.vue?vue&type=script&setup=true&lang.ts (15:26) "useAddonWaline" is not exported by "node_modules/.pnpm/valaxy@0.18.1_@types+markdown-it@13.0.7_@unhead+shared@1.8.10_postcss@8.4.35_typescript@5.3.3_unhead@1.8.10/node_modules/valaxy/client/addons/index.ts", imported by "node_modules/.pnpm/valaxy-theme-yun@0.18.1/node_modules/valaxy-theme-yun/components/third/YunWaline.vue?vue&type=script&setup=true&lang.ts".
node_modules/.pnpm/valaxy-theme-yun@0.18.1/node_modules/valaxy-theme-yun/components/third/YunAlgoliaSearch.vue?vue&type=script&setup=true&lang.ts (21:53) "useAddonAlgolia" is not exported by "node_modules/.pnpm/valaxy@0.18.1_@types+markdown-it@13.0.7_@unhead+shared@1.8.10_postcss@8.4.35_typescript@5.3.3_unhead@1.8.10/node_modules/valaxy/client/addons/index.ts", imported by "node_modules/.pnpm/valaxy-theme-yun@0.18.1/node_modules/valaxy-theme-yun/components/third/YunAlgoliaSearch.vue?vue&type=script&setup=true&lang.ts".

[vite-ssg] Build for server...
node_modules/.pnpm/valaxy-theme-yun@0.18.1/node_modules/valaxy-theme-yun/components/third/YunTwikoo.vue?vue&type=script&setup=true&lang.ts (16:14) "useTwikooWithOptions" is not exported by "node_modules/.pnpm/valaxy@0.18.1_@types+markdown-it@13.0.7_@unhead+shared@1.8.10_postcss@8.4.35_typescript@5.3.3_unhead@1.8.10/node_modules/valaxy/client/addons/index.ts", imported by "node_modules/.pnpm/valaxy-theme-yun@0.18.1/node_modules/valaxy-theme-yun/components/third/YunTwikoo.vue?vue&type=script&setup=true&lang.ts".
node_modules/.pnpm/valaxy-theme-yun@0.18.1/node_modules/valaxy-theme-yun/components/third/YunWaline.vue?vue&type=script&setup=true&lang.ts (17:26) "useAddonWaline" is not exported by "node_modules/.pnpm/valaxy@0.18.1_@types+markdown-it@13.0.7_@unhead+shared@1.8.10_postcss@8.4.35_typescript@5.3.3_unhead@1.8.10/node_modules/valaxy/client/addons/index.ts", imported by "node_modules/.pnpm/valaxy-theme-yun@0.18.1/node_modules/valaxy-theme-yun/components/third/YunWaline.vue?vue&type=script&setup=true&lang.ts".
node_modules/.pnpm/valaxy-theme-yun@0.18.1/node_modules/valaxy-theme-yun/components/third/YunAlgoliaSearch.vue?vue&type=script&setup=true&lang.ts (23:53) "useAddonAlgolia" is not exported by "node_modules/.pnpm/valaxy@0.18.1_@types+markdown-it@13.0.7_@unhead+shared@1.8.10_postcss@8.4.35_typescript@5.3.3_unhead@1.8.10/node_modules/valaxy/client/addons/index.ts", imported by "node_modules/.pnpm/valaxy-theme-yun@0.18.1/node_modules/valaxy-theme-yun/components/third/YunAlgoliaSearch.vue?vue&type=script&setup=true&lang.ts".

[vite-ssg] Rendering Pages... (53)
[vite-ssg] Critical CSS generation enabled via `critters`
file:///C:/Users/baiiylu/work/valaxy-blog/node_modules/.pnpm/vite-ssg@0.23.6_critters@0.0.20_vite@5.1.3_vue-router@4.2.5_vue@3.4.19/node_modules/vite-ssg/dist/node.mjs:1058
        throw new Error(`${gray("[vite-ssg]")} ${red(`Error on page: ${cyan(route)}`)}
              ^

Error: [vite-ssg] Error on page: /posts/2022
TypeError: src.replace is not a function
    at Object.escapeHtmlComment (C:\Users\baiiylu\work\valaxy-blog\node_modules\.pnpm\@vue+shared@3.4.19\node_modules\@vue\shared\dist\shared.cjs.js:407:14)
    at renderVNode (C:\Users\baiiylu\work\valaxy-blog\node_modules\.pnpm\@vue+server-renderer@3.4.19_vue@3.4.19\node_modules\@vue\server-renderer\dist\server-renderer.cjs.prod.js:467:34)
    at renderComponentSubTree (C:\Users\baiiylu\work\valaxy-blog\node_modules\.pnpm\@vue+server-renderer@3.4.19_vue@3.4.19\node_modules\@vue\server-renderer\dist\server-renderer.cjs.prod.js:445:7)
    at renderComponentVNode (C:\Users\baiiylu\work\valaxy-blog\node_modules\.pnpm\@vue+server-renderer@3.4.19_vue@3.4.19\node_modules\@vue\server-renderer\dist\server-renderer.cjs.prod.js:376:12)
    at ssrRenderComponent (C:\Users\baiiylu\work\valaxy-blog\node_modules\.pnpm\@vue+server-renderer@3.4.19_vue@3.4.19\node_modules\@vue\server-renderer\dist\server-renderer.cjs.prod.js:84:10)
    at file:///C:/Users/baiiylu/work/valaxy-blog/node_modules/.pnpm/valaxy@0.18.1_@types+markdown-it@13.0.7_@unhead+shared@1.8.10_postcss@8.4.35_typescript@5.3.3_unhead@1.8.10/node_modules/valaxy/client/.vite-ssg-temp/dl1mq297p6/main.mjs:6418:13
    at renderComponentSubTree (C:\Users\baiiylu\work\valaxy-blog\node_modules\.pnpm\@vue+server-renderer@3.4.19_vue@3.4.19\node_modules\@vue\server-renderer\dist\server-renderer.cjs.prod.js:430:9)
    at renderComponentVNode (C:\Users\baiiylu\work\valaxy-blog\node_modules\.pnpm\@vue+server-renderer@3.4.19_vue@3.4.19\node_modules\@vue\server-renderer\dist\server-renderer.cjs.prod.js:376:12)
    at renderVNode (C:\Users\baiiylu\work\valaxy-blog\node_modules\.pnpm\@vue+server-renderer@3.4.19_vue@3.4.19\node_modules\@vue\server-renderer\dist\server-renderer.cjs.prod.js:490:14)
    at renderComponentSubTree (C:\Users\baiiylu\work\valaxy-blog\node_modules\.pnpm\@vue+server-renderer@3.4.19_vue@3.4.19\node_modules\@vue\server-renderer\dist\server-renderer.cjs.prod.js:445:7)
    at file:///C:/Users/baiiylu/work/valaxy-blog/node_modules/.pnpm/vite-ssg@0.23.6_critters@0.0.20_vite@5.1.3_vue-router@4.2.5_vue@3.4.19/node_modules/vite-ssg/dist/node.mjs:1058:15
    at async file:///C:/Users/baiiylu/work/valaxy-blog/node_modules/.pnpm/vite-ssg@0.23.6_critters@0.0.20_vite@5.1.3_vue-router@4.2.5_vue@3.4.19/node_modules/vite-ssg/dist/node.mjs:707:36

Node.js v21.4.0
 ELIFECYCLE  Command failed with exit code 1.

Reproduction

pnpm run build

System Info

System:
    OS: Windows 11 10.0.22621
    CPU: (20) x64 13th Gen Intel(R) Core(TM) i9-13900H
    Memory: 14.73 GB / 31.63 GB
  Binaries:
    Node: 21.4.0 - C:\Program Files\nodejs\node.EXE
    npm: 10.4.0 - C:\Program Files\nodejs\npm.CMD
    pnpm: 8.15.3 - ~\AppData\Local\pnpm\pnpm.EXE
  Browsers:
    Edge: Chromium (121.0.2277.128)
    Internet Explorer: 11.0.22621.1

Used Package Manager

pnpm

Validations

MengNianxiaoyao commented 8 months ago

请将子文件内的一个md文档重命名为index.md

YunYouJun commented 8 months ago

请提供可复现文件。

MengNianxiaoyao commented 8 months ago

但这样这篇文章的路径名就不具有可读性了

MengNianxiaoyao commented 8 months ago

请提供可复现文件。

这里的报错是子文件夹缺少了一个index.md的文件,构建不出来名为2022.html这个文件

zsbai commented 8 months ago

@YunYouJun 出现问题的是posts目录,故无法提供可复现文件... 不过只要 posts 目录下有子目录的时候就会报错,这是我的 posts 结构,每个子目录内都有数篇 md 后缀的博文:

├─posts
│  ├─2022
│  ├─2023
│  └─2024

当删除子目录,只在 posts 目录留有md文件就可以编译成功

@MengNianxiaoyao 方法确实可行,经过测试并不需要修改博文名称,只需要在每个子目录内新建一个名为 index.md 的空文件就可以构建成功了

更新... 新建空的 index.md 会多出来空博文,还是要修改旧博文名称... 图片

YunYouJun commented 8 months ago

给个测试用例,可能是多方因素导致的。只是描述会忽略很多问题。

zsbai commented 8 months ago

给个测试用例,可能是多方因素导致的。只是描述会忽略很多问题。

请查看:zsbai/valaxy-test

此仓库可以复现构建问题,GitHub Action中有相关日志:https://github.com/zsbai/valaxy-test/actions/runs/7990544710/job/21819591074

测试完成后请告知~方便删除测试仓库

YunYouJun commented 8 months ago

大致知道原因了,这是一个边界情况,你可以通过 index.md 临时解决,稍后会修复。

YunYouJun commented 8 months ago

Fixed in v0.18.3