事件

Hexo 继承自 EventEmitter。使用 on 方法监听 Hexo 触发的事件,使用 emit 方法触发事件。有关更多信息,请参阅 Node.js API 文档。

¥Hexo inherits from EventEmitter. Use the on method to listen for events emitted by Hexo, and use the emit method to emit events. For more information, refer to the Node.js API documentation.

deployBefore

部署开始前触发。

¥Emitted before deployment begins.

deployAfter

部署完成后触发。

¥Emitted after deployment finishes.

exit

Hexo 退出前触发。

¥Emitted before Hexo exits.

generateBefore

生成开始前触发。

¥Emitted before generation begins.

generateAfter

生成完成后触发。

¥Emitted after generation finishes.

new

新帖子创建后触发。此事件返回帖子数据:

¥Emitted after a new post has been created. This event returns the post data:

hexo.on("new", function (post) {
//
});
数据 描述
post.path 帖子文件的完整路径
post.content 帖子文件的内容

processBefore

处理开始前触发。此事件返回表示框根目录的路径。

¥Emitted before processing begins. This event returns a path representing the root directory of the box.

processAfter

处理完成后触发。此事件返回表示框根目录的路径。

¥Emitted after processing finishes. This event returns a path representing the root directory of the box.

ready

初始化完成后触发。

¥Emitted after initialization finishes.