@@ -45,13 +45,17 @@ const PRETTIFIER_SCRIPT_FILES = [
4545let idToDoc /*: Map<string, Doc> */ ;
4646
4747exports . publish = ( options /*: PublishOptions */ ) => {
48+ const config = options . config ;
49+
50+ linker . siteRoot = config . template . siteRoot ;
51+
4852 const docTree = options . documentTree ;
4953 const outDir = path . normalize ( options . config . opts . destination ) ;
5054 const index = linker . createURI ( "index" ) ;
5155
5256 fse . ensureDir ( outDir ) ;
5357
54- const crawlData = crawl ( docTree ) ;
58+ const crawlData = crawl ( docTree , index ) ;
5559 const renderer = new TemplateRenderer ( path . join ( __dirname , "tmpl" ) , null , docTree )
5660 . setLayoutTemplate ( "layout.tmpl" )
5761 . installPlugin ( "linker" , linker )
@@ -168,13 +172,18 @@ function outIndexes(
168172 config /*: WebdocConfig */ ,
169173 index , /*: Index */
170174) {
175+ const siteRoot = `/${ config . template . siteRoot } ` ;
171176 const KEY_TO_TITLE = {
172177 "classes" : "Class Index" ,
173178 } ;
174179
175180 function outIndex ( indexKey , indexList ) {
176181 const title = KEY_TO_TITLE [ indexKey ] ;
177- const url = indexList . url ;
182+ let url = indexList . url ;
183+
184+ if ( url . startsWith ( siteRoot ) ) {
185+ url = url . slice ( siteRoot . length ) ;
186+ }
178187
179188 pipeline . render ( "pages/api-index.tmpl" , {
180189 documentList : indexList ,
@@ -196,12 +205,17 @@ function outReference(
196205 config /*: WebdocConfig */ ,
197206 docTree , /*: RootDoc */
198207) {
208+ const siteRoot = `/${ config . template . siteRoot } ` ;
209+
199210 for ( const [ id , docRecord ] of linker . documentRegistry ) {
200- const { uri : page } = docRecord ;
211+ let { uri : page } = docRecord ;
201212
202213 if ( page . includes ( "#" ) ) {
203214 continue ; // skip fragments (non-standalone docs)
204215 }
216+ if ( page . startsWith ( siteRoot ) ) {
217+ page = page . slice ( siteRoot . length ) ;
218+ }
205219
206220 let doc ;
207221
0 commit comments