创建帖子
¥Create a Post
hexo.post.create(data, replace); |
参数 | 描述 |
---|---|
data |
数据 |
replace |
替换现有文件 |
帖子的属性可以在 data
中定义。下表并不详尽。可以在前言中附加其他属性。
¥The attributes of a post can be defined in data
. The table below is not exhaustive. Additional attributes may be appended to the front-matter.
数据 | 描述 |
---|---|
title |
标题 |
slug |
URL |
layout |
布局。默认为 default_layout 设置。 |
path |
路径。Hexo 默认根据 new_post_path 设置构建帖子路径。 |
date |
日期。默认为当前日期。 |
发布草稿
¥Publish a Draft
hexo.post.publish(data, replace); |
参数 | 描述 |
---|---|
data |
数据 |
replace |
替换现有文件 |
帖子的属性可以在 data
中定义。下表并不详尽。可以在前言中附加其他属性。
¥The attributes of a post can be defined in data
. The table below is not exhaustive. Additional attributes may be appended to the front-matter.
数据 | 描述 |
---|---|
slug |
文件名(必填) |
layout |
布局。默认为 default_layout 设置。 |
渲染
¥Render
hexo.post.render(source, data); |
参数 | 描述 |
---|---|
source |
文件的完整路径(可选) |
data |
数据 |
数据必须包含 content
属性。如果没有,Hexo 将尝试读取原始文件。此功能的执行步骤如下:
¥The data must contain the content
attribute. If not, Hexo will try to read the original file. The execution steps of this function are as follows: