mirror of https://github.com/ethereum/go-ethereum
parent
9748bdfd0c
commit
ec7773916b
@ -1,11 +1,19 @@ |
||||
import { LAST_COMMIT_BASE_URL } from '../constants'; |
||||
|
||||
export const getLastModifiedDate = async (filePath: string) => |
||||
fetch(`${LAST_COMMIT_BASE_URL}${filePath}/index.md&page=1&per_page=1`) |
||||
export const getLastModifiedDate = async (filePath: string) => { |
||||
const headers = new Headers({ |
||||
// Note: this token expires on Dec 16, 2023
|
||||
// check fine-grained tokens https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token#about-personal-access-tokens
|
||||
Authorization: 'Token ' + process.env.GITHUB_TOKEN_READ_ONLY |
||||
}); |
||||
|
||||
return fetch(`${LAST_COMMIT_BASE_URL}${filePath}/index.md&page=1&per_page=1`, { headers }) |
||||
.then(res => res.json()) |
||||
.then(commits => commits[0].commit.committer.date) |
||||
.catch(_ => |
||||
fetch(`${LAST_COMMIT_BASE_URL}${filePath}.md&page=1&per_page=1`) |
||||
fetch(`${LAST_COMMIT_BASE_URL}${filePath}.md&page=1&per_page=1`, { headers }) |
||||
.then(res => res.json()) |
||||
.then(commits => commits[0].commit.committer.date) |
||||
.catch(console.error) |
||||
); |
||||
}; |
||||
|
Loading…
Reference in new issue