hexo的post创建过程
要讲hexo的post.create先要看它的传入参数。
1 | this.post.create(data, args.r || args.replace) |
data定义如下:
1 | var data = { |
hexo/post.js:
1 | Post.prototype.create = function(data, replace, callback){ |
1 | ctx.execFilter('new_post_path', data, { |
执行new_post_path类型的过滤器,hexo/index.js代码如下:
1 | Hexo.prototype.execFilter = function(type, data, options){ |
路径hexo/extend/filter.js:
1 | Filter.prototype.exec = function(type, data, options){ |
这里我们执行的是new_post_path的filter:
文件路径为hexo/lib/plugins/filter/new_post_path.js
1 | function newPostPathFilter(data, replace){ |