Router

  • 2018-12-03

Router는 사이트의 모든 경로를 저장합니다.

경로 가져오기

get 메소드는 Stream을 반환합니다. 아래는 특정한 목적지로 가기 위한 경로 데이터를 저장하는 동작 예시입니다.

1
2
3
4
var data = hexo.route.get('index.html');
var dest = fs.createWriteStream('somewhere');

data.pipe(dest);

경로 설정하기

set 메소드는 문자열과 Buffer 또는 함수를 통해 얻어옵니다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// String
hexo.route.set('index.html', 'index')

// Buffer
hexo.route.set('index.html', new Buffer('index'));

// Function (Promise)
hexo.route.set('index.html', function(){
return new Promise(function(resolve, reject){
resolve('index');
});
});

// Function (Callback)
hexo.route.set('index.html', function(callback){
callback(null, 'index');
});

경로가 수정되었는지 아닌지에 대해 boolean값을 통해 확인할 수 있습니다. 이는 수정되지 않은 파일을 무시하여 파일의 빠른 생성을 도와줍니다.

1
2
3
4
5
6
hexo.route.set('index.html', {
data: 'index',
modified: false
});

// hexo.route.isModified('index.html') => false

경로 제거하기

1
hexo.route.remove('index.html');

경로(route) 목록 가져오기

1
hexo.route.list();

경로 형식 지정하기

format 메소드는 문자열을 사용 가능한 경로로 변환해줍니다.

1
2
hexo.route.format('archives/');
// archives/index.html

扫码领红包

2018双11超级红包
PC访问链接: 2018双11超级红包 预售开启 汇聚全球潮流新品

淘口令:¥20Y0b6q4eHR¥ (复制此行再打开手机淘宝客访问)

最后更新: 2018年12月03日 09:29

原始链接: https://cyc.oy99.com/ko/api/router.html

× 多少都行~
打赏二维码
×
  • {title}