@@ -88,39 +88,41 @@ CreateDatajs('./.deploy/js/dt.js',function(dt_path,arr){
8888 ReadTmpToHTML ( '/template/details.ejs' , dep + '.html' , md_path + '.md' , itm )
8989 } ) ;
9090
91+ console . log ( success ( " → " ) , arr . length )
92+
9193} )
9294
9395
94- // 监听实时编译
95- watch . watchTree ( path . join ( path . dirname ( __dirname ) , '/' ) , function ( f , curr , prev ) {
96- if ( typeof f == "object" && prev === null && curr === null ) {
97- console . log ( success ( " → :watching " ) + '/template/' ) ;
98- // Finished walking the tree
99- } else if ( prev === null ) {
96+ // // 监听实时编译
97+ // watch.watchTree(path.join(path.dirname(__dirname),'/'), function (f, curr, prev) {
98+ // if (typeof f == "object" && prev === null && curr === null) {
99+ // console.log(success(" → :watching ") + '/template/');
100+ // // Finished walking the tree
101+ // } else if (prev === null) {
100102
101- // f is a new file
102- } else if ( curr . nlink === 0 ) {
103- // f was removed
104- } else {
103+ // // f is a new file
104+ // } else if (curr.nlink === 0) {
105+ // // f was removed
106+ // } else {
105107
106- if ( / \. s t y l $ / . test ( f ) ) {
107- CreateStyl ( '/template/styl/index.styl' , '/.deploy/css/index.css' )
108- } else if ( / \. j s $ / . test ( f ) ) {
108+ // if(/\.styl$/.test(f)){
109+ // CreateStyl('/template/styl/index.styl','/.deploy/css/index.css')
110+ // }else if(/\.js$/.test(f)){
109111
110- CreateJS ( '/template/js/index.js' , '/.deploy/js/index.js' )
112+ // CreateJS('/template/js/index.js','/.deploy/js/index.js')
111113
112- } else if ( / \. e j s $ / . test ( f ) ) {
113- // 首页生成
114- ReadTmpToHTML ( '/template/index.ejs' , '/.deploy/index.html' ) ;
115- ReadTmpToHTML ( '/template/list.ejs' , '/.deploy/list.html' ) ;
114+ // }else if(/\.ejs$/.test(f)){
115+ // // 首页生成
116+ // ReadTmpToHTML('/template/index.ejs','/.deploy/index.html');
117+ // ReadTmpToHTML('/template/list.ejs','/.deploy/list.html');
116118
117- } else if ( / \. m d $ / . test ( f ) ) {
118- var mdp = f . replace ( path_root , '' ) ;
119- var dep = path . join ( '/.deploy/' , mdp ) ;
120- ReadTmpToHTML ( '/template/details.ejs' , dep . replace ( '.md' , '.html' ) , mdp ) ;
121- }
122- }
123- } )
119+ // }else if(/\.md$/.test(f)){
120+ // var mdp = f.replace(path_root,'');
121+ // var dep = path.join('/.deploy/',mdp);
122+ // ReadTmpToHTML('/template/details.ejs',dep.replace('.md','.html'),mdp);
123+ // }
124+ // }
125+ // })
124126
125127
126128function CreateJS ( from_path , to_path ) {
@@ -220,6 +222,7 @@ function CreateDatajs(dt_path,callback){
220222 if ( ! exists ( path_md ) ) return console . log ( "\n → error: 文件夹 " + path_md + " 不存在 \n " )
221223 // 获取 markdown 目录的集合
222224 var path_arr = readMDSync ( path_md ) ;
225+ path_arr = sortLength ( path_arr ) ;
223226 var indexes = [ ]
224227 path_arr . forEach ( function ( md_path , i ) {
225228 var json = { }
@@ -243,6 +246,21 @@ function CreateDatajs(dt_path,callback){
243246 } ) ;
244247}
245248
249+ // 按长度排序
250+ function sortLength ( arr ) {
251+ var compare = function ( x , y ) { //比较函数
252+ x = path . basename ( x , '.md' ) ;
253+ y = path . basename ( y , '.md' ) ;
254+ if ( x . length < y . length ) {
255+ return - 1 ;
256+ } else if ( x . length > y . length ) {
257+ return 1 ;
258+ } else {
259+ return 0 ;
260+ }
261+ }
262+ return arr . sort ( compare )
263+ }
246264
247265// 同步循环创建所有目录 resolvePath
248266function mkdirsSync ( dirpath , mode , callback ) {
0 commit comments