ルーターはサイトで使用されるすべてのパスを保存します。
パスの取得
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/');
|