mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
62c61b754d
This commit introduces additional stage in the process of generating html docs from markdown files. Plugin transforms links to *.md files in the respository to links to *.html files in the online documentation. Fixes: https://github.com/nodejs/node/issues/28689 PR-URL: https://github.com/nodejs/node/pull/29946 Reviewed-By: Anna Henningsen <anna@addaleax.net>
22 lines
433 B
JavaScript
22 lines
433 B
JavaScript
'use strict';
|
|
|
|
const visit = require('unist-util-visit');
|
|
|
|
module.exports = {
|
|
replaceLinks
|
|
};
|
|
|
|
function replaceLinks({ filename, linksMapper }) {
|
|
return (tree) => {
|
|
const fileHtmlUrls = linksMapper[filename];
|
|
|
|
visit(tree, 'definition', (node) => {
|
|
const htmlUrl = fileHtmlUrls && fileHtmlUrls[node.identifier];
|
|
|
|
if (htmlUrl && typeof htmlUrl === 'string') {
|
|
node.url = htmlUrl;
|
|
}
|
|
});
|
|
};
|
|
}
|