企业🤖AI Agent构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
# 路由 路由存储了网站中所用到的所有路径。 ## 获取路径 `get` 方法会传回一个 [Stream](http://nodejs.org/api/stream.html),例如把该路径的资料存储到某个指定位置。 ``` var'index.html' var'somewhere' data.pipe(dest); ``` ## 设置路径 您可以在 `set` 方法中使用字符串、[Buffer](http://nodejs.org/api/buffer.html) 或函数,如下: ``` // String hexo.route.set('index.html''index' // Buffer hexo.route.set('index.html'new'index' // Function (Promise) hexo.route.set('index.html'function{ returnnewPromisefunctionresolve, reject{ resolve('index' });});// Function (Callback) hexo.route.set('index.html'functioncallback{ callback(null'index' }); ``` 您还可以设置该路径是否更新,这样在生成文件时便能忽略未更动的文件,加快生成时间。 ``` hexo.route.set('index.html' data: 'index' modified: false });// hexo.route.isModified('index.html') => false ``` ## 移除路径 ``` hexo.route.remove('index.html' ``` ## 获得路由表 ``` hexo.route.list(); ``` ## 格式化路径 `format` 方法可将字符串转为合法的路径。 ``` hexo.route.format('archives/' // archives/index.html ```