ppoffice / hexo-theme-icarus

A simple, delicate, and modern theme for the static site generator Hexo.
https://ppoffice.github.io/hexo-theme-icarus/
MIT License
6.36k stars 1.55k forks source link

本地运行主题无法显示 #1058

Closed ppwwyyxx closed 2 years ago

ppwwyyxx commented 2 years ago

Bug描述 主题无法显示. 和 https://github.com/ppoffice/hexo-theme-icarus/issues/855 相同. #855 未被解决.

系统与环境 以下提供一个dockerfile进行复现.

复现方式

$cat Dockerfile
FROM archlinux:latest
RUN pacman --noconfirm -Sy npm
RUN npm i -g hexo
RUN hexo version
RUN hexo init blog
RUN cd blog && npm i hexo-theme-icarus@4.5.0 && hexo config theme icarus && hexo clean
$ docker build  -t blog:v0 .
$ docker run -p 4000:4000 -it blog:v0 bash -c 'cd blog && hexo s'

打开浏览器输入localhost:4000, 得到以下内容 (与#855 一样):

const { Component } = require('inferno'); const classname = require('hexo-component-inferno/lib/util/classname'); const Head = require('./common/head'); const Navbar = require('./common/navbar'); const Widgets = require('./common/widgets'); const Footer = require('./common/footer'); const Scripts = require('./common/scripts'); const Search = require('./common/search'); module.exports = class extends Component { render() { const { site, config, page, helper, body } = this.props; const language = page.lang || page.language || config.language; const columnCount = Widgets.getColumnCount(config.widgets, config, page); return
; } };
ppoffice commented 2 years ago

https://ppoffice.github.io/hexo-theme-icarus/uncategorized/%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98/#%E7%AB%99%E7%82%B9

ppwwyyxx commented 2 years ago

Icarus运行在Node.js 8.3.0或更新的版本上。 它同时依赖Hexo 4.2.0或更新版本。

版本符合要求.

除此之外,请确保所有的Node.js依赖已安装。 你可以在/package.json 文件的peerDependencies部分下找到这些依赖。

对一个nodejs 依赖合理的预期行为是以下两种之一:

理想情况下, 用户不应被预期自行安装需要的依赖.

因此, 如果这个issue是由于依赖缺失导致, 那么它仍然应属于此项目的bug.

同时,从你的站点中移除所有无用的Node.js依赖,否则它们可能会导致Icarus出现奇怪的问题。

我提供的复现过程证明, 复现此issue并不需要安装任何额外 "无用的" nodejs 依赖, 只使用了hexo init.

如果hexo init本身所产生的依赖中就包含"无用的"nodejs依赖 而需要被移除的话, 那么这个issue将很大概率被所有hexo用户遇到. 此种情况下应该 (i) 解决这种依赖冲突, 或 (ii) 在README中注明常见的需要移除的依赖.

最后, 请注意复现此issue的步骤完全符合README中所声称的安装方式且没有任何额外步骤. 按照此安装方式无法成功安装, 意味着项目需要在(i) 修复安装失败的原因 和 (ii) 修正README中的说明 中至少实现一项.

由于以上所述关于此项目的问题未被解决, 此issue也不应该被关闭.

ppoffice commented 2 years ago

抱歉,我检查了下主题在Hexo 6下确实不会报错。最新的commit已经修复了这个问题。

ppwwyyxx commented 2 years ago

十分感谢!

FROM archlinux:latest
RUN pacman --noconfirm -Sy npm git
RUN npm i -g hexo-cli
RUN hexo version
RUN hexo init blog
RUN cd blog && npm i hexo@6.0.0 --save && npm i https://github.com/ppoffice/hexo-theme-icarus && hexo config theme icarus && hexo clean

使用以上dockerfile, issue已不再出现.