最后修改时间
获取 Github 仓库中文件最后编辑时间
用法
传入你的仓库名称,以及文件路径。
import { getGithubLastEdit } from 'fumadocs-core/server';
const time = await getGithubLastEdit({
owner: 'fuma-nama',
repo: 'fumadocs',
// example: "content/docs/index.mdx"
path: `content/docs/${page.path}`,
});Github Token
注意,你在开发模式下很容易达到速率限制。因此,你 应该传入 Github token 以获得更高的速率限制。
了解更多关于 Authenticating to the REST API。
import { getGithubLastEdit } from 'fumadocs-core/server'
const time = await getGithubLastEdit({
...,
token: `Bearer ${process.env.GIT_TOKEN}`
})此外,如果你不需要该功能,你也可以在开发模式下跳过此步骤。
process.env.NODE_ENV === 'development'? null : getGithubLastEdit(...)How is this guide?
Last updated on
