new Hexo( [cwd])
初始化
Parameters:
Name | Type | Argument | Default | Description |
---|---|---|---|---|
cwd |
String |
<optional> |
process.cwd() | 工作路径 |
Methods
-
<async> addPost(options)
-
新建一篇文章
Parameters:
Name Type Description options
Object 新建参数 Properties
Name Type Argument Description title
String 文章名 slug
String <optional>
网址,参见hexo API Returns:
- 新建的文章- Type
- Post
-
<async> clean()
-
清理hexo数据
-
<async> deletePost(_id)
-
删除一篇文章
Parameters:
Name Type Description _id
String 文章id Returns:
- 被删除的文章- Type
- Post
-
<async> deploy()
-
部署网站
-
<async> getPost(_id)
-
获取单篇文章
Parameters:
Name Type Description _id
String 文章id Returns:
- 文章对象,如果没有则为`null`- Type
- Post | null
-
<async> init(cwd)
-
初始化并开始监听文件
Parameters:
Name Type Description cwd
String Hexo博客目录 -
<async> listCategories()
-
获取分类列表
Returns:
- 分类列表- Type
- Array.<Object>
-
<async> listPosts()
-
获取文章列表
Returns:
- 文章列表- Type
- Array.<Post>
-
<async> listTags()
-
获取标签列表
Returns:
- 标签对象列表- Type
- Array.<Object>
-
<async> publishPost(_id)
-
发布文章
Parameters:
Name Type Description _id
String 文章id Returns:
- 发布后的文章,**注意,id会改变!**- Type
- Post
-
<async> resetGit()
-
重置本地文件
-
<async> saveGit()
-
保存到git
-
<async> syncGit()
-
从GIT同步
-
<async> unpublishPost(_id)
-
取消发布文章
Parameters:
Name Type Description _id
String 文章id Returns:
- 取消发布后的文章,**注意,id会改变!**- Type
- Post
-
<async> updatePost(options)
-
更新一篇文章
Parameters:
Name Type Description options
Object 更新参数 Properties
Name Type Description _id
String 文章id _whe_delete
Array 需要删除的键的数组 Returns:
- 更新过的文章- Type
- Post