Git Last Edit
Get the last edit time of a file in Git
Pass your repository name, and the path to file.
import { getGitLastEditTime } from 'next-docs-zeta/server'
const time = await getGitLastEditTime(
'SonMooSans/next-docs',
'content/' + page._raw.sourceFilePath
)
Notice that you may easily reach the rate limit in development mode. Hence, you
should pass a Github token for a higher rate limit.
Learn more about
Authenticating to the REST API.
import { getGitLastEditTime } from 'next-docs-zeta/server'
const time = await getGitLastEditTime(
'SonMooSans/next-docs',
'content/' + page._raw.sourceFilePath,
undefined,
{
headers: {
Authorization: 'Bearer xxx'
}
}
)
Also, you can skip this in development mode if you don't need that
functionality.
process.env.NODE_ENV === 'development'? null : getGitLastEditTime(...)