For AI agents: the complete documentation index is available at https://rspress.rs/zh/llms.txt, the full documentation bundle is available at https://rspress.rs/zh/llms-full.txt, and this page is available as Markdown at https://rspress.rs/zh/ui/components/source-code.md.
close
  • 中文
  • SourceCode

    SourceCode 用于渲染仓库源码的链接。

    用法

    index.mdx
    import { SourceCode } from '@rspress/core/theme';
    
    <SourceCode href="https://github.com/web-infra-dev/rspress/blob/main/packages/theme-default/src/components/SourceCode/index.tsx" />

    Props

    interface SourceCodeProps {
      /** 源码链接 */
      href: string;
      /** 代码托管平台,决定显示的图标 */
      platform?: 'github' | 'gitlab';
    }

    通过 platform 切换 GitHub/GitLab 图标,默认为 'github'