File tree 4 files changed +19
-2
lines changed
4 files changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ index_generator:
24
24
per_page : 10
25
25
order_by : -date
26
26
pagination_dir : page
27
+ layout : ["index", "archive"]
27
28
` ` `
28
29
29
30
- **path**: Root path for your blog's index page.
@@ -36,6 +37,8 @@ index_generator:
36
37
- **pagination_dir**: URL format.
37
38
- default : ` page`
38
39
- e.g. set `awesome-page` makes the URL ends with `awesome-page/<page number>` for second page and beyond.
40
+ - **layout**: custom layout.
41
+ - defalut : ` ["index", "archive"]`
39
42
40
43
# # Usage
41
44
Original file line number Diff line number Diff line change 4
4
5
5
hexo . config . index_generator = Object . assign ( {
6
6
per_page : typeof hexo . config . per_page === 'undefined' ? 10 : hexo . config . per_page ,
7
- order_by : '-date'
7
+ order_by : '-date' ,
8
+ layout : [ 'index' , 'archive' ]
8
9
} , hexo . config . index_generator ) ;
9
10
10
11
hexo . extend . generator . register ( 'index' , require ( './lib/generator' ) ) ;
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ module.exports = function(locals) {
13
13
14
14
return pagination ( path , posts , {
15
15
perPage : config . index_generator . per_page ,
16
- layout : [ 'index' , 'archive' ] ,
16
+ layout : config . index_generator . layout || [ 'index' , 'archive' ] ,
17
17
format : paginationDir + '/%d/' ,
18
18
data : {
19
19
__index : true
Original file line number Diff line number Diff line change @@ -148,4 +148,17 @@ describe('Index generator', () => {
148
148
result [ 2 ] . path . should . eql ( 'yoyo/3/' ) ;
149
149
150
150
} ) ;
151
+
152
+ it ( 'custom layout' , ( ) => {
153
+ const custom_layout = [ 'custom' , 'archive' , 'index' ] ;
154
+ hexo . config . index_generator . layout = [ ...custom_layout ] ;
155
+
156
+ const result = generator ( locals ) ;
157
+
158
+ result . forEach ( res => {
159
+ res . layout . should . eql ( custom_layout ) ;
160
+ } ) ;
161
+
162
+ } ) ;
163
+
151
164
} ) ;
You can’t perform that action at this time.
0 commit comments