File tree Expand file tree Collapse file tree 2 files changed +51
-7
lines changed Expand file tree Collapse file tree 2 files changed +51
-7
lines changed Original file line number Diff line number Diff line change @@ -54,12 +54,21 @@ const Defaulter = {
54
54
* @param pageName
55
55
*/
56
56
function defaulter ( pageName ) {
57
- const tags = _ . get ( pagesConfig , pageName + '.tags' , defaults . tags ) ;
58
- const description = _ . get (
59
- pagesConfig ,
60
- pageName + '.description' ,
61
- defaults . description
62
- ) ;
57
+ let tags = defaults . tags ;
58
+ let description = defaults . description ;
59
+ if (
60
+ _ . isPlainObject ( pagesConfig ) &&
61
+ pagesConfig . hasOwnProperty ( pageName ) &&
62
+ _ . isPlainObject ( pagesConfig [ pageName ] )
63
+ ) {
64
+ const pageConfig = pagesConfig [ pageName ] ;
65
+ if ( Array . isArray ( pageConfig . tags ) ) {
66
+ tags = pageConfig . tags ;
67
+ }
68
+ if ( _ . isString ( pageConfig . description ) ) {
69
+ description = pageConfig . description ;
70
+ }
71
+ }
63
72
return {
64
73
name : pageName ,
65
74
tags : tags . filter ( _ . isString ) ,
Original file line number Diff line number Diff line change @@ -94,13 +94,18 @@ describe('指定pluginOptions.navigator', () => {
94
94
page1 : {
95
95
tags : [ 'page' ] ,
96
96
description : "i'm page1"
97
+ } ,
98
+ 'page3.dot' : {
99
+ tags : [ 'dot page' ] ,
100
+ description : 'my name have a dot!'
97
101
}
98
102
}
99
103
} ;
100
104
const projectOptions = {
101
105
pages : {
102
106
page1 : './page1.js' ,
103
- page2 : './page2.js'
107
+ page2 : './page2.js' ,
108
+ 'page3.dot' : './page3.js'
104
109
} ,
105
110
pluginOptions : {
106
111
navigator : originalOptions
@@ -178,5 +183,35 @@ describe('指定pluginOptions.navigator', () => {
178
183
}
179
184
) ;
180
185
} ) ;
186
+ describe ( 'page3.dot' , ( ) => {
187
+ it (
188
+ 'page3.dot的tags为: ' +
189
+ originalOptions . pages [ 'page3.dot' ] . tags . join ( ',' ) ,
190
+ ( ) => {
191
+ expect (
192
+ Array . isArray ( finalOptions . pages [ 'page3.dot' ] . tags )
193
+ ) . toBe ( true ) ;
194
+ expect ( finalOptions . pages [ 'page3.dot' ] . tags . length ) . toBe (
195
+ originalOptions . pages [ 'page3.dot' ] . tags . length
196
+ ) ;
197
+ expect (
198
+ sameArray (
199
+ finalOptions . pages [ 'page3.dot' ] . tags ,
200
+ originalOptions . pages [ 'page3.dot' ] . tags
201
+ )
202
+ ) . toBe ( true ) ;
203
+ }
204
+ ) ;
205
+
206
+ it (
207
+ 'page3.dot的description为: ' +
208
+ originalOptions . pages [ 'page3.dot' ] . description ,
209
+ ( ) => {
210
+ expect ( finalOptions . pages [ 'page3.dot' ] . description ) . toBe (
211
+ originalOptions . pages [ 'page3.dot' ] . description
212
+ ) ;
213
+ }
214
+ ) ;
215
+ } ) ;
181
216
} ) ;
182
217
} ) ;
You can’t perform that action at this time.
0 commit comments