@@ -22,8 +22,11 @@ const {categoryFilterPlugin} = require("./helper/renderer-plugins/category-filte
2222/*::
2323import type {
2424 Doc,
25- RootDoc
25+ RootDoc,
26+ TutorialDoc,
2627} from "@webdoc/types";
28+
29+ import type {CrawlData} from './crawl';
2730*/
2831
2932Object . assign ( linker . standaloneDocTypes , [
@@ -96,6 +99,7 @@ exports.publish = async function publish(options /*: PublishOptions */) {
9699 outMainPage ( path . join ( outDir , indexRelative ) , pipeline , options . config ) ;
97100 outIndexes ( outDir , pipeline , options . config , crawlData . index ) ;
98101 outReference ( outDir , pipeline , options . config , docTree ) ;
102+ outTutorials ( outDir , pipeline , options . config , docTree ) ;
99103
100104 pipeline . close ( ) ;
101105} ;
@@ -130,6 +134,17 @@ function outExplorerData(outDir /*: string */, crawlData /*: CrawlData */) {
130134 ( err ) => {
131135 if ( err ) throw err ;
132136 } ) ;
137+
138+ if ( crawlData . tutorials ) {
139+ fse . writeFile (
140+ path . join ( explorerDir , "./tutorials.json" ) ,
141+ JSON . stringify ( crawlData . tutorials ) ,
142+ "utf8" ,
143+ ( err ) => {
144+ if ( err ) throw err ;
145+ } ,
146+ ) ;
147+ }
133148 } ) ;
134149}
135150
@@ -175,7 +190,7 @@ async function outReadme(
175190 }
176191
177192 pipeline . render ( "pages/main-page.tmpl" , {
178- docs : [ ] ,
193+ document : null ,
179194 readme,
180195 title : "Documentation" ,
181196 env : config ,
@@ -247,7 +262,7 @@ function outReference(
247262 ) ;
248263 } else {
249264 pipeline . render ( "document.tmpl" , {
250- docs : [ doc ] ,
265+ document : doc ,
251266 title : doc . name ,
252267 env : config ,
253268 } , {
@@ -256,3 +271,26 @@ function outReference(
256271 }
257272 }
258273}
274+
275+ function outTutorials (
276+ outDir /*: string */ ,
277+ pipeline /*: TemplatePipeline */ ,
278+ config /*: WebdocConfig */ ,
279+ docTree /*: RootDoc */ ,
280+ ) {
281+ function out ( tutorial /*: TutorialDoc */ ) {
282+ const uri = linker . getURI ( tutorial ) ;
283+
284+ pipeline . render ( "tutorial.tmpl" , {
285+ document : tutorial ,
286+ title : tutorial . title ,
287+ env : config ,
288+ } , {
289+ outputFile : path . join ( outDir , uri ) ,
290+ } ) ;
291+
292+ tutorial . members . forEach ( ( out /*: any */ ) ) ;
293+ }
294+
295+ docTree . tutorials . forEach ( out ) ;
296+ }
0 commit comments