File tree 4 files changed +25
-6
lines changed
4 files changed +25
-6
lines changed Original file line number Diff line number Diff line change
1
+ 'use strict'
2
+
3
+ const AsyncOption = require ( '../abstract/AsyncOption' )
4
+
5
+ /**
6
+ * additionalPages option.
7
+ */
8
+
9
+ module . exports = class AdditionalPagesOption extends AsyncOption {
10
+ async apply ( ctx ) {
11
+ await super . asyncApply ( )
12
+
13
+ await Promise . all (
14
+ this . appliedValues . map ( async ( options ) => {
15
+ await ctx . addPage ( options )
16
+ } )
17
+ )
18
+ }
19
+ }
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ const ClientDynamicModulesOption = require('./ClientDynamicModulesOption')
3
3
const GlobalUIComponentsOption = require ( './GlobalUIComponentsOption' )
4
4
const DefineOption = require ( './DefineOption' )
5
5
const AliasOption = require ( './AliasOption' )
6
+ const AdditionalPagesOption = require ( './AdditionalPagesOption' )
6
7
const Option = require ( '../abstract/Option' )
7
8
const { PLUGIN_OPTION_MAP } = require ( '../constants' )
8
9
@@ -23,6 +24,9 @@ module.exports = function instantiateOption (name) {
23
24
case PLUGIN_OPTION_MAP . ALIAS . name :
24
25
return new AliasOption ( name )
25
26
27
+ case PLUGIN_OPTION_MAP . ADDITIONAL_PAGES . name :
28
+ return new AdditionalPagesOption ( name )
29
+
26
30
default : return new Option ( name )
27
31
}
28
32
}
Original file line number Diff line number Diff line change @@ -103,11 +103,7 @@ module.exports = class AppContext {
103
103
this . markdown = createMarkdown ( this )
104
104
105
105
await this . resolvePages ( )
106
- await Promise . all (
107
- this . pluginAPI . options . additionalPages . values . map ( async ( options ) => {
108
- await this . addPage ( options )
109
- } )
110
- )
106
+ await this . pluginAPI . options . additionalPages . apply ( this )
111
107
112
108
await this . pluginAPI . options . ready . apply ( )
113
109
await Promise . all ( [
Original file line number Diff line number Diff line change @@ -354,7 +354,7 @@ export default {
354
354
355
355
## additionalPages
356
356
357
- - Type: ` Array|Function `
357
+ - Type: ` Array|AsyncFunction `
358
358
- Default: ` undefined `
359
359
360
360
Add a page pointing to a markdown file:
You can’t perform that action at this time.
0 commit comments