• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2
3const visit = require('unist-util-visit');
4
5module.exports = {
6  replaceLinks
7};
8
9function replaceLinks({ filename, linksMapper }) {
10  return (tree) => {
11    const fileHtmlUrls = linksMapper[filename];
12
13    visit(tree, 'definition', (node) => {
14      const htmlUrl = fileHtmlUrls && fileHtmlUrls[node.identifier];
15
16      if (htmlUrl && typeof htmlUrl === 'string') {
17        node.url = htmlUrl;
18      }
19    });
20  };
21}
22