build(aio): refactor dgeni packages
This is to tidy up the `author-packagse`, which currently duplicates a lot of the configuration in the main packages. We need to DRY this up so that we don't fall foul of a change in one being missed in the other.
This commit is contained in:

committed by
Pete Bacon Darwin

parent
7a8bd99ab1
commit
3cad5da5a4
24
aio/tools/transforms/angular-base-package/processors/fixInternalDocumentLinks.js
vendored
Normal file
24
aio/tools/transforms/angular-base-package/processors/fixInternalDocumentLinks.js
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
/**
|
||||
* @dgProcessor fixInternalDocumentLinks
|
||||
* @description
|
||||
* Add in the document path to links that start with a hash.
|
||||
* This is important when the web app has a base href in place,
|
||||
* since links like: `<a href="#some-id">` would get mapped to
|
||||
* the URL `base/#some-id` even if the current location is `base/some/doc`.
|
||||
*/
|
||||
module.exports = function fixInternalDocumentLinks() {
|
||||
|
||||
var INTERNAL_LINK = /(<a [^>]*href=")(#[^"]*)/g;
|
||||
|
||||
return {
|
||||
$runAfter: ['inlineTagProcessor'],
|
||||
$runBefore: ['convertToJsonProcessor'],
|
||||
$process: function(docs) {
|
||||
docs.forEach(doc => {
|
||||
doc.renderedContent = doc.renderedContent.replace(INTERNAL_LINK, (_, pre, hash) => {
|
||||
return pre + doc.path + hash;
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
Reference in New Issue
Block a user