# Fumadocs Core (the core library of Fumadocs): 最後修改時間
URL: /zh-TW/docs/headless/utils/git-last-edit
Source: https://raw.githubusercontent.com/fuma-nama/fumadocs/refs/heads/main/apps/docs/content/docs/headless/utils/git-last-edit.zh-TW.mdx

取得 GitHub 儲存庫中檔案的最後編輯時間

## 使用方式 [#usage]

請傳入您的儲存庫名稱及檔案路徑。

```ts
import { getGithubLastEdit } from 'fumadocs-core/content/github';

const time = await getGithubLastEdit({
  owner: 'fuma-nama',
  repo: 'fumadocs',
  // 範例："content/docs/index.mdx"
  path: `content/docs/${page.path}`,
});
```

### Github Token [#github-token]

請注意，在開發模式下很容易就會達到速率限制，因此建議您傳入 Github token，以取得較高的速率限制。

進一步了解
[向 REST API 進行驗證](https://docs.github.com/en/rest/overview/authenticating-to-the-rest-api)。

```ts
import { getGithubLastEdit } from 'fumadocs-core/content/github'

 const time = await getGithubLastEdit({
    ...,
    token: `Bearer ${process.env.GIT_TOKEN}`
  })
```

此外，若您在開發模式下不需要此功能，也可以略過這個步驟。

```ts
process.env.NODE_ENV === 'development'? null : getGithubLastEdit(...)
```

### 自訂 GitHub 基礎 URL [#custom-github-base-url]

如果您需要存取的 GitHub 執行個體位於 `https://api.github.com` 以外的 URL，可以覆寫基礎 URL：

```ts
import { getGithubLastEdit } from 'fumadocs-core/content/github';

const time = await getGithubLastEdit({
  owner: 'your-org',
  repo: 'your-repo',
  path: `content/docs/${page.path}`,
  baseUrl: 'https://api.octocorp.ghe.com', // 您的自訂 GitHub API URL
});
```

若未指定，`baseUrl` 參數的預設值為 `'https://api.github.com'`。