@@ -3,27 +3,23 @@ var types_1 = require('./types');
33var coderoad_cli_1 = require ( 'coderoad-cli' ) ;
44var fs_1 = require ( 'fs' ) ;
55var path_1 = require ( 'path' ) ;
6+ var pageNew_1 = require ( './utils/pageNew' ) ;
67var _tutorial = {
7- title : '' ,
8- pages : [ {
9- file : './01/page-01.md' ,
10- title : 'Page One' ,
11- description : 'page one description' ,
12- tasks : [ {
13- tests : [ './01/01.js' ] ,
14- description : 'first task' ,
15- hints : [ 'hint 1' , 'hint 2' ]
16- } ]
17- } ]
8+ info : {
9+ title : '' ,
10+ description : '' ,
11+ } ,
12+ pages : [ ] . concat ( pageNew_1 . default ( 0 ) )
1813} ;
1914function tutorial ( t , action ) {
2015 if ( t === void 0 ) { t = _tutorial ; }
2116 switch ( action . type ) {
2217 case types_1 . TUTORIAL_INIT :
2318 var _a = action . payload , dir = _a . dir , name_1 = _a . name ;
2419 coderoad_cli_1 . create ( dir , name_1 ) ;
25- if ( _tutorial . title . length < 1 ) {
26- t = Object . assign ( { } , t , { title : name_1 } ) ;
20+ if ( _tutorial . info . title . length < 1 ) {
21+ var info = Object . assign ( { } , t . info , { title : name_1 } ) ;
22+ t = Object . assign ( { } , t , { info : info } ) ;
2723 }
2824 return t ;
2925 case types_1 . TUTORIAL_BUILD :
@@ -32,6 +28,9 @@ function tutorial(t, action) {
3228 case types_1 . TUTORIAL_LOAD :
3329 var data = JSON . parse ( fs_1 . readFileSync ( path_1 . join ( action . payload . dir , 'coderoad.json' ) , 'utf8' ) ) ;
3430 return data ;
31+ case types_1 . TUTORIAL_PAGE_ADD :
32+ var pages = t . pages . concat ( pageNew_1 . default ( t . pages . length ) ) ;
33+ return Object . assign ( { } , t , { pages : pages } ) ;
3534 default :
3635 return t ;
3736 }
0 commit comments