github.com/lmittmann/w3@v0.20.0/docs/components/DocLink.jsx (about)

     1  import { Link } from 'nextra-theme-docs'
     2  import { Code } from 'nextra/components'
     3  
     4  const pkgNameToPath = {
     5      'w3': 'github.com/lmittmann/w3',
     6      'module': 'github.com/lmittmann/w3/module',
     7      'debug': 'github.com/lmittmann/w3/module/debug',
     8      'eth': 'github.com/lmittmann/w3/module/eth',
     9      'txpool': 'github.com/lmittmann/w3/module/txpool',
    10      'web3': 'github.com/lmittmann/w3/module/web3',
    11      'w3types': 'github.com/lmittmann/w3/w3types',
    12      'w3vm': 'github.com/lmittmann/w3/w3vm',
    13      'hooks': 'github.com/lmittmann/w3/w3vm/hooks',
    14      'tracing': 'github.com/ethereum/go-ethereum/core/tracing',
    15      'logger': 'github.com/ethereum/go-ethereum/eth/tracers/logger',
    16  }
    17  
    18  export const DocLink = ({ title, id }) => {
    19      if (typeof id === 'undefined') { id = title }
    20      let dotIndex = id.indexOf('.');
    21      let pkg = id.substring(0, dotIndex);
    22      let comp = id.substring(dotIndex + 1);
    23  
    24      return (
    25          <Link href={`https://pkg.go.dev/${pkgNameToPath[pkg]}#${comp}`}>
    26              <Code>{title}</Code>
    27          </Link>
    28      )
    29  }