@@ -40,13 +40,29 @@ async function readSite(siteRoot) {
40
40
} ) ;
41
41
} ) ;
42
42
43
+ // Cross-link all prev/next pages
44
+ var pageByUrl = Object . create ( null ) ;
45
+ for ( var i = 0 ; i < site . files . length ; i ++ ) {
46
+ pageByUrl [ path . resolve ( site . files [ i ] . url ) ] = site . files [ i ] ;
47
+ }
48
+
49
+ for ( var i = 0 ; i < site . files . length ; i ++ ) {
50
+ var page = site . files [ i ] ;
51
+ if ( page . next ) {
52
+ page . nextPage = pageByUrl [ path . resolve ( page . url , page . next ) ] ;
53
+ }
54
+ }
55
+
43
56
return site ;
44
57
}
45
58
46
- function buildSite ( buildRoot , site ) {
47
- return Promise . all ( site . files . map ( file => {
48
- return writer ( buildRoot , file , site ) ;
49
- } ) ) ;
59
+ function buildSite ( buildRoot , site , filter ) {
60
+ return Promise . all ( site . files
61
+ . filter ( file =>
62
+ ! filter ||
63
+ ( filter . test ? filter . test ( file . absPath ) : filter === file . absPath ) )
64
+ . map ( file => writer ( buildRoot , file , site ) )
65
+ ) ;
50
66
}
51
67
52
68
@@ -91,6 +107,8 @@ function readFileData(absPath, relPath, stat) {
91
107
function normalizeData ( file ) {
92
108
file . isPage = file . content && isPageish ( file . relPath ) ;
93
109
file . url = urlToFile ( file ) ;
110
+ var dirname = path . dirname ( file . relPath ) ;
111
+ file . dir = dirname === '.' ? 'docs' : dirname . split ( '/' ) [ 0 ] ;
94
112
file . date = file . date ?
95
113
Date . parse ( file . date ) :
96
114
( file . stat . birthtime || file . stat . ctime ) ;
@@ -123,6 +141,11 @@ function urlToFile(file) {
123
141
}
124
142
}
125
143
144
+ // Convert .less to .css
145
+ if ( path . extname ( url ) === '.less' ) {
146
+ url = url . slice ( 0 , - 5 ) + '.css' ;
147
+ }
148
+
126
149
// Assume index.html stands for the parent directory
127
150
if ( path . basename ( url ) === 'index.html' ) {
128
151
url = path . dirname ( url ) ;
0 commit comments