theme-shoka-x / hexo-theme-shokaX

a hexo theme based on shoka
https://docs-hexo.shokax.top
GNU Affero General Public License v3.0
291 stars 39 forks source link

_cover_index is not a function #320

Open clown-q opened 1 month ago

clown-q commented 1 month ago

在开始之前......

问题发生位置

Hexo渲染报错

问题描述

Unhandled rejection TypeError: F:\blog\themes\shokax\layout_partials\layout.pug:9 7| - ignores.push(theme.quicklink.ignores) 8|

9| - var covers = _cover_index(page, 6) 10| - var enableFixedCover = theme.homeConfig?.fixedCover 11| 12| doctype html

_cover_index is not a function at eval (eval at wrap (F:\blog_clown\node_modules.pnpm\pug-runtime@3.0.1\node_modules\pug-runtime\wrap.js:6:10), :631:14) at template (eval at wrap (F:\blog_clown\node_modules.pnpm\pug-runtime@3.0.1\node_modules\pug-runtime\wrap.js:6:10), :1187:7) at _View._compiled (F:\blog_clown\node_modules.pnpm\hexo@7.3.0_chokidar@3.6.0\node_modules\hexo\dist\theme\view.js:120:67) at _View.render (F:\blog_clown\node_modules.pnpm\hexo@7.3.0_chokidar@3.6.0\node_modules\hexo\dist\theme\view.js:37:21) at F:\blog_clown\node_modules.pnpm\hexo@7.3.0_chokidar@3.6.0\node_modules\hexo\dist\hexo\index.js:60:29 at tryCatcher (F:\blog_clown\node_modules.pnpm\bluebird@3.7.2\node_modules\bluebird\js\release\util.js:16:23) at F:\blog_clown\node_modules.pnpm\bluebird@3.7.2\node_modules\bluebird\js\release\method.js:15:34 at RouteStream._read (F:\blog_clown\node_modules.pnpm\hexo@7.3.0_chokidar@3.6.0\nodemodules\hexo\dist\hexo\router.js:43:9) at Readable.read (node:internal/streams/readable:496:12) at resume (node:internal/streams/readable:999:12) at process.processTicksAndRejections (node:internal/process/task_queues:82:21)

复现步骤

cd themes git clone https://github.com/theme-shoka-x/hexo-theme-shokaX.git cd shokax node ./toolbox/compiler.mjs cd ../.. hexo s

相关配置

No response

注意事项

zkz098 commented 1 month ago

编译完成之后scripts文件夹是不是空的

如果是这就是一个已知问题,tsc在编译时会莫名其妙地在路径后加一个\n并导致编译失败,这个\n不清楚是哪步被加入的,node侧进行的任何处理都无法去除,所以编译TS可能产生空的scripts目录。后续考虑使用esbuild替换tsc来尝试解决此问题。

临时解决方案(二选一):

  1. 在scripts目录下使用npx -p typescript tsc --build并输入yes手动编译,随后再运行toolbox删除ts文件
  2. 从最新版npm包里拿一个编译后的scripts替换掉空scripts
clown-q commented 1 month ago

我使用第一种临时解决了上面的问题,感谢