GitHubCode 组件允许您包含来自 Cloudflare 仓库的文件。
可以通过行或用标签包裹的区域来过滤远程内容。
import { GitHubCode } from "~/components";import { GitHubCode } from "~/components";
<GitHubCode
repo="cloudflare/workflows-starter"
file="src/index.ts"
commit="a844e629ec80968118d4b116d4b26f5dcb107137"
lang="ts"
useTypeScriptExample={true}
/>import { GitHubCode } from "~/components";
{/*
import { foo } from "bar";
const baz = foo();
console.log(baz);
*/}
<GitHubCode
repo="..."
file="..."
commit="..."
lang="..."
lines="1-3"
/>
{/*
import { foo } from "bar";
const baz = foo();
*/}import { GitHubCode } from "~/components";
{/*
<docs-tag name="no-logging">
import { foo } from "bar";
const baz = foo();
</docs-tag name="no-logging">
console.log(baz);
*/}
<GitHubCode
repo="..."
file="..."
commit="..."
lang="..."
tag="no-logging"
/>
{/*
import { foo } from "bar";
const baz = foo();
*/}必需
类型: string
要拉取的拥有者和仓库,格式为 cloudflare/<REPO-NAME>
例如:
cloudflare/workers-rs。cloudflare/templates。
必需
类型: string
要拉取的文件路径,格式为 path/to/filename-including-extensions。此路径不包含仓库名称。
例如:
templates/hello-world/src/lib.rs。d1-starter-sessions-api/src/index.ts。
必需
类型: string
要拉取的长(40 字符)Git 提交哈希值(Git commit hash),例如 ab3951b5c95329a600a7baa9f9bb1a7a95f1aeaa。
必需
类型: string
用于代码块的语言,例如 rs。
类型: boolean
如果 lang 是 "ts" 且 useTypeScriptExample 为 true,则将使用 TypeScriptExample 组件来同时提供 JavaScript 选项卡。
类型: string
用于过滤内容的行范围,例如 1-3。
类型: string
用于过滤内容的区域,例如 no-logging。
这应在源文件中表示为开始注释 <docs-tag name="no-logging"> 和结束注释 </docs-tag name="no-logging">。
类型: object
传递给 Expressive Code 组件 ↗ 的属性。