@@ -135,7 +135,7 @@ module.exports = function dabFactory(ngIoProjPath) {
135
135
assert ( depth === 1 || depth == 2 , 'depth ' + depth ) ;
136
136
const jadeFilePath = path . resolve ( outFileNoExtn + '.jade' ) ;
137
137
const breadcrumbs = $ ( 'header > nav ol.breadcrumbs' ) ;
138
- fs . writeFileSync ( jadeFilePath , apiEntryJadeTemplate ( depth , breadcrumbs , div ) ) ;
138
+ fs . writeFileSync ( jadeFilePath , apiEntryJadeTemplate ( $ , depth , breadcrumbs , div ) ) ;
139
139
// In case harp cached the .html version, remove it since it will be generated.
140
140
try {
141
141
fs . unlinkSync ( path . resolve ( outFileNoExtn + '.html' ) ) ;
@@ -197,17 +197,29 @@ module.exports = function dabFactory(ngIoProjPath) {
197
197
return _self ;
198
198
} ;
199
199
200
+ function _adjustAnchorHref ( $ , $elt , hrefPathPrefix ) {
201
+ if ( ! hrefPathPrefix ) return ;
202
+ $elt . find ( 'a[href]' ) . each ( ( i , e ) => {
203
+ let href = $ ( e ) . attr ( 'href' )
204
+ // Do nothing to absolute or external links
205
+ if ( href . match ( / ^ \/ | ^ [ a - z ] + : / ) ) return ;
206
+ $ ( e ) . attr ( 'href' , `${ hrefPathPrefix } /${ href } ` ) ;
207
+ } ) ;
208
+ }
209
+
200
210
function _indentedEltHtml ( $elt , i , filterFnOpt ) {
201
211
let lines = $elt . html ( ) . split ( '\n' ) ;
202
212
if ( filterFnOpt ) lines = lines . filter ( filterFnOpt ) ;
203
213
const indent = ' ' . substring ( 0 , i ) ;
204
214
return lines . map ( ( line ) => `${ indent } | ${ line } ` ) . join ( '\n' ) ;
205
215
}
206
216
207
- function apiEntryJadeTemplate ( baseHrefDepth , $breadcrumbs , $mainDiv ) {
217
+ function apiEntryJadeTemplate ( $ , baseHrefDepth , $breadcrumbs , $mainDiv ) {
208
218
const baseHref = path . join ( ...Array ( baseHrefDepth ) . fill ( '..' ) ) ;
209
219
// TODO/investigate: for some reason $breadcrumbs.html() is missing the <ol></ol>. We add it back in the template below.
220
+ _adjustAnchorHref ( $ , $breadcrumbs , baseHref ) ;
210
221
const breadcrumbs = _indentedEltHtml ( $breadcrumbs , 6 , ( line ) => ! line . match ( / ^ \s * $ / ) ) ;
222
+ _adjustAnchorHref ( $ , $mainDiv , baseHref ) ;
211
223
const mainDivHtml = _indentedEltHtml ( $mainDiv , 4 ) ;
212
224
// WARNING: since the following is Jade, indentation is significant.
213
225
const result = `
@@ -217,8 +229,8 @@ include ${baseHref}/../_util-fns
217
229
218
230
block head-extra
219
231
// generated Dart API page template: head-extra
220
- //- <base> is required because all the links in dartdoc generated pages are "pseudo-absolute"
221
- base(href="${ baseHref } ")
232
+ //- <base> is no longer required
233
+ //- base(href="${ baseHref } ")
222
234
223
235
block breadcrumbs
224
236
// generated Dart API page template: breadcrumbs
0 commit comments