build(aio): local assets are not dangling links

Closes #16615
Closes #16616
This commit is contained in:
Peter Bacon Darwin
2017-05-08 15:38:52 +01:00
committed by Pete Bacon Darwin
parent 1af42aedfa
commit 0190df9cf3
2 changed files with 14 additions and 3 deletions

View File

@ -9,7 +9,9 @@ const Package = require('dgeni').Package;
const gitPackage = require('dgeni-packages/git');
const apiPackage = require('../angular-api-package');
const contentPackage = require('../angular-content-package');
const { extname } = require('canonical-path');
const { extname, resolve } = require('canonical-path');
const { existsSync } = require('fs');
const { SRC_PATH } = require('../config');
module.exports = new Package('angular.io', [gitPackage, apiPackage, contentPackage])
@ -32,4 +34,12 @@ module.exports = new Package('angular.io', [gitPackage, apiPackage, contentPacka
checkAnchorLinksProcessor.checkDoc = (doc) => doc.path && doc.outputPath && extname(doc.outputPath) === '.json';
// Since we have a `base[href="/"]` arrangement all links are relative to that and not relative to the source document's path
checkAnchorLinksProcessor.base = '/';
// Ignore links to local assets
// (This is not optimal in terms of performance without making changes to dgeni-packages there is no other way.
// That being said do this only add 500ms onto the ~30sec doc-gen run - so not a huge issue)
checkAnchorLinksProcessor.ignoredLinks.push({
test(url) {
return (existsSync(resolve(SRC_PATH, url)));
}
});
});