Skip to content

Commit 0190df9

Browse files
build(aio): local assets are not dangling links
Closes #16615 Closes #16616
1 parent 1af42ae commit 0190df9

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

‎aio/tools/transforms/angular.io-package/index.js‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ const Package = require('dgeni').Package;
99
const gitPackage = require('dgeni-packages/git');
1010
const apiPackage = require('../angular-api-package');
1111
const contentPackage = require('../angular-content-package');
12-
const { extname } = require('canonical-path');
12+
const { extname, resolve } = require('canonical-path');
13+
const { existsSync } = require('fs');
14+
const { SRC_PATH } = require('../config');
1315

1416
module.exports = new Package('angular.io', [gitPackage, apiPackage, contentPackage])
1517

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

‎aio/tools/transforms/config.js‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ const AIO_PATH = resolve(PROJECT_ROOT, 'aio');
66
const TEMPLATES_PATH = resolve(AIO_PATH, 'tools/transforms/templates');
77
const API_TEMPLATES_PATH = resolve(TEMPLATES_PATH, 'api');
88
const CONTENTS_PATH = resolve(AIO_PATH, 'content');
9-
const OUTPUT_PATH = resolve(AIO_PATH, 'src/generated');
9+
const SRC_PATH = resolve(AIO_PATH, 'src');
10+
const OUTPUT_PATH = resolve(SRC_PATH, 'generated');
1011
const DOCS_OUTPUT_PATH = resolve(OUTPUT_PATH, 'docs');
1112
const API_SOURCE_PATH = resolve(PROJECT_ROOT, 'packages');
1213

@@ -17,5 +18,5 @@ function requireFolder(dirname, folderPath) {
1718
.map(p => require(resolve(absolutePath, p)));
1819
}
1920

20-
module.exports = { PROJECT_ROOT, AIO_PATH, TEMPLATES_PATH, API_TEMPLATES_PATH, CONTENTS_PATH, OUTPUT_PATH, DOCS_OUTPUT_PATH, API_SOURCE_PATH, requireFolder };
21+
module.exports = { PROJECT_ROOT, AIO_PATH, TEMPLATES_PATH, API_TEMPLATES_PATH, CONTENTS_PATH, SRC_PATH, OUTPUT_PATH, DOCS_OUTPUT_PATH, API_SOURCE_PATH, requireFolder };
2122

0 commit comments

Comments
 (0)