blob: 97feadbf9990bb92484c201b9274885b096025c4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
'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;
}
});
};
}
|