Routerは、サイトで使用されているすべてのパスを保存します。
パスの取得
get
メソッドは、Streamを返します。たとえば、pathデータを指定された先に保存するには
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/");
|