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/core/src/theme/components/SourceCode/index.tsx" />

你也可以将 SourceCode 放在标题同一行。源码链接会显示在正文标题中,不会出现在页内目录中,也不会改变标题锚点。

import { SourceCode } from '@rspress/core/theme';

## Google Analytics <SourceCode href="https://github.com/rstackjs/rspress-plugins" />

Props

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

href

  • 类型:string
  • 必填

源码链接。

platform

  • 类型:'github' | 'gitlab'
  • 默认值:'github'

切换 GitHub 和 GitLab 图标。