路由儲存了網站中使用的所有路徑。
取得路徑
get
方法會回傳一個 Stream。例如,將路徑資料儲存到指定目的地:
var data = hexo.route.get("index.html"); var dest = fs.createWriteStream("somewhere");
data.pipe(dest);
|
設定路徑
set
方法接受字串、Buffer 或函式。
hexo.route.set("index.html", "index");
hexo.route.set("index.html", new Buffer("index"));
hexo.route.set("index.html", function () { return new Promise(function (resolve, reject) { resolve("index"); }); });
hexo.route.set("index.html", function (callback) { callback(null, "index"); });
|
你也可以設定布林值來表示路徑是否被修改過。這可以加速檔案產生,因為它允許忽略未修改的檔案。
hexo.route.set("index.html", { data: "index", modified: false, });
|
移除路徑
hexo.route.remove("index.html");
|
取得路由列表
格式化路徑
format
方法會將字串轉換為有效的路徑。
hexo.route.format("archives/");
|